sverx / devkitSMS

development kit and libraries for SEGA Master System / SEGA Game Gear / SEGA SG-1000 / SEGA SC-3000 homebrew programming using C language (and the SDCC compiler)
217 stars 33 forks source link

I cannot compile this unless I add #include <stdbool.h> to SMSlib.h #1

Closed ComputerNerd closed 9 years ago

ComputerNerd commented 9 years ago

I am wondering how you were able to compile devkitSMS without the extra include. What stdbool.h does according to http://pubs.opengroup.org/onlinepubs/9699919799//basedefs/stdbool.h.html is expand bool to _Bool which allows me to compile it. Doing a search and replace for bool changing it to _Bool also allows me to compile it.

In C there is no keyword that I am aware of called bool; only _Bool please see http://en.cppreference.com/w/c/keyword.

I am using the latest snapshot of SDCC as of the time of writing the issue which is: 3.5.2 #9277

sverx commented 9 years ago

SMSlib.c does in fact include stdbool.h and you should also include it in your sources, before including SMSlib.h

ComputerNerd commented 9 years ago

Do you mean in main.c I should add #include "SMSlib.c"?

What I have right now works without that include and in fact including SMSlib.c as if it were a header will cause multiple definition problems if you have multiple source code files.

Here is how I currently compile devkitSMS along with my project https://github.com/ComputerNerd/Retro-Graphics-Toolkit/blob/master/examples/masterSystem/C/Makefile All the makefile does is just compile all sources listed in the SOURCE variable and then link together all the generated object files.

sverx commented 9 years ago

I meant you should also include stdbool.h in your C source, before including SMSlib.h

ComputerNerd commented 9 years ago

Sorry for the confusion that does make much more sense. I thought the intention was that SMSlib.h should be able to function without any prerequisites. Also I should have been more clear that I meant using SMSlib.h in my code. I used bad wording initially.

sverx commented 9 years ago

I followed your suggestion and switched from 'bool' to '_Bool'. Also, the library now resets the sprites on initialization. Thanks for your comments!