Error when compiling for simulator


#1

Hi,
I just ordered a Pokitto and wanted to practice in the simulator before it arrives.
I set up codeblocks but when i rebuild i get this error.

according to stackoverflow i need to put
#undef max
#undef min
somewhere into the code, however i do not know where


#2

Try to put it above the template.

The problem seems to be there is a min macro defined somewhere and when the compiler comes to the screenshot line, it thinks you’re using the macro, but it’s actually a function definition, so you should say you want to invalidate the macro somewhere before the compiler comes to this line.


#3

@Xhaku :

Caused by conflict between min/max macros (AVR compatibility) and stdlib min/max functions

Put #define DISABLEAVRMIN in your My_settings.h OR put DISABLEAVRMIN=1 in project build options


#4

Another familiar face I see. :P


I take it you’re trying to get one of your Arduboy games running?

If so which one(s)?

It might not run because the version of Arduboy2 packaged in Arduboy2Lib is out-of-date.

stl_algobase is a system file used to implement the standard library.
@Xhaku can’t alter that or they risk upsetting the standard library in general,
possibly causing knock-on effects with other games/programs.

This is the general answer, but it also depends on the program being compiled.

If that program needs the macro form of min and max then disabling the AVR compatibility will cause problems,
but at the same time not disabling it will prevent the algorithm standard header from compiling.

So basically it’s a bit of a ‘catch-22’ so we might need more details if using #define DISABLEAVRMIN doesn’t work.
(In particular, where and why is #include <algorithm> occurring.)


#6

Hey,
I just downloaded the Pokitto_sim and tried to build it and run the built in hello world example.
I have not changed a thing


#7

@Xhaku : Pokitto_sim is deprecated. Use this instead:

The sim part with its .cdb (code::blocks) project file is under the POKITTO_SIM folder


#8

Yes this is the tutorial i originally followed and where i got the error


#9

Aha… let me check nothing is the matter. There should not be any errors.


#10

I put #define DISABLEAVRMIN into My_settings.h for the built in hello world example and it works.
This solution doesent work for 101Starships_GB. I either get the same error or a new error where it says that min is not defined


#11

I just pulled the repo and built the HelloWorld with no changes: 0 errors. Windows 10, Code::Blocks 16.01

EDIT: you have 17.12 … that may affect the result.

Let me install 17.12 and check on another machine

What OS are you on? edit: nevermind, i looked at the pic :laughing:


#12

@Xhaku :

I just cloned the repo again, and built the HelloWorld target with a fresh Code::Blocks 17.12 installation, no problems at all

Please copy paste your entire build log here so I can take a look at it


#13

my build log is right here http://freetexthost.com/mxlbwcgzsc
this is when i tried to build for the 101Starships_GB


#14

Looks like the problem is that MinGW’s version of GCC 6.3.0’s version of the standard library is including algorithm in its stdint.h implementation for some reason.

‘Legally’ that’s permitted, but rather awkward.

Checking my version of Code::Blocks, it seems I’ve got it set it to use 4.9.2 and that doesn’t seem to be causing me issues.

@jonne, what version of GCC is your Code::Blocks using?


That’s exactly the ‘catch-22’ situation I mentioned earlier.

One way to fix that is to #define DISABLEAVRMIN in My_settings.h, and then at the top of the main file for 101Starships_GB (which I’m assuming is called main.cpp), make sure you #include <Pokitto.h> first, and then right after that put:

#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))

It’s not ideal, but it should work.


#15

@jonne

While reading through the build log I noticed these three warnings:

C:UsersFlorimDesktopPokittoLib-masterPokittoLib-masterPokittoPOKITTO_COREPokittoCookie.cpp||In member function 'bool Pokitto::Cookie::saveCookie()':|
C:UsersFlorimDesktopPokittoLib-masterPokittoLib-masterPokittoPOKITTO_COREPokittoCookie.cpp|129|warning: control reaches end of non-void function [-Wreturn-type]|
C:UsersFlorimDesktopPokittoLib-masterPokittoLib-masterPokittoPOKITTO_COREPokittoCookie.cpp||In member function 'bool Pokitto::Cookie::loadCookie()':|
C:UsersFlorimDesktopPokittoLib-masterPokittoLib-masterPokittoPOKITTO_COREPokittoCookie.cpp|138|warning: control reaches end of non-void function [-Wreturn-type]|
C:UsersFlorimDesktopPokittoLib-masterPokittoLib-masterPokittoPOKITTO_COREPokittoCookie.cpp||In member function 'int Pokitto::Cookie::findMyNextBlock()':|
C:UsersFlorimDesktopPokittoLib-masterPokittoLib-masterPokittoPOKITTO_COREPokittoCookie.cpp|361|warning: control reaches end of non-void function [-Wreturn-type]|

I don’t like warnings and these are potentially serious issues, so I made a PR to fix them:


#16

i have removed the other compiler and installed 4.9.2.
The min max problem is gone however now i get another error.
I am trying to build the hello world example from the pokitto simlator.
Maybe you could take a look at it?
The problem seems to be this line

C:\Users\Florim\Desktop\PokittoLib-master\PokittoLib-master\Pokitto\POKITTO_CORE\PokittoConsole.cpp|83|error: cast from ‘char*’ to ‘uint32_t {aka unsigned int}’ loses precision [-fpermissive]|

the full log is here http://freetexthost.com/gd6j5ekpoe


#17

I’m guessing that’s because you’re compiling for a 64 bit CPU/OS so a pointer is 64 bits.

I’ll make a PR to the library tomorrow to fix that.

In the meantime you can try to set the compiler to compile a 32-bit program or you can pass the -fpermissive flag to the compiler through the build settings.
(And if you don’t know how to do either of those, I’ll tell you tomorrow.)


#18

i have tried to add -fpermissive which got rid of the error but then i got other errors which i think were also 64bit related so i removed the compiler again and installed the 32bit compiler.
Now everything seems to be working.
Thank you and Jonne for your help cant wait to get into the Pokitto especially the color display :slight_smile:


#19

BTW nice to see you here :slight_smile: Loved your Arduboy games, can’t wait for what you do with Pokitto.


#20

Thanks I actually bought the Pokitto because of you. I was checking out your raycastLib and saw a gif of an example on the Pokitto. For some reason that was enough for me to buy it.


#21

This means very much to me, I’m really very happy you liked it so much.

Until the Pokitto arrives, also try out the emulator:

I now prefer it to the simulator for the development because it behaves more like the actual hardware. I still use the simulator for debugging (with that you can normally print to console, use valgrind on the executable etc.).

EDIT: Apparently emulator now supports printf too :slight_smile: