Jump to content

Issue with GFX_COMPILER and TRUE/FALSE


woodstock

Recommended Posts

Another preprocessor definition-related problem: when gfx.h is included it defines TRUE and FALSE before including gfxconf.h. This is definitely necessary, as pointed out by the comment immediately preceding those two definitions, however neither GFX_COMPILER_ARMCC or GFX_COMPILER_KEIL have been defined by this stage – hence the compiler warning. This is a new warning as a result of the ff01cc0 commit 'Adding GFX_COMPILER_ARMCC and GFX_COMPILER_KEIL'.

The real problem here though relates to how (I think) this is interpreted by the preprocessor. It is my understanding that if GFX_COMPILER_ARMCC and GFX_COMPILER_KEIL have not yet been defined they will be treated as a value of 0, which would match the value of GFX_COMPILER if it has been set to GFX_COMPILER_UNKNOWN (or if it has not been defined itself). So I think the preprocessor statements on line 39 of gfx.h will always be evaluated as true (unless these defines have been made prior) and therefore TRUE will always be defined as 1.

Another potential issue I have picked up is discrepancies in the definition of TRUE for GCC/ChibiOS. First up, I have noticed that TRUE is defined as -1 in gos_chibios.h, whereas it has been defined as 1 in ChibiOS/os/rt/ports/ARMCMx/compilers/GCC/chtypes.h and various other GCC-port files within the ChibiOS source.

I'm sorry I don't have any solutions this time. :?

Link to comment
Share on other sites

Thank you for bringing this to our attention.

This is a stupid issue introduced by me because I was being stupid and didn't think this through. Let me explain: The reason I added the check for GFX_COMPILER_KEIL and GFX_COMPILER_ARMCC to the define of TRUE was, because I couldn't compile otherwise becaus ethe ARMCC/Keil preprocessor screwed some things up and the #if checks didn't work properly.

It was a long night and I wanted to get this done before bed time so that Keil support would finally be completed. I took a look at the documentation and it seemed like Keil/ARMCC uses a define of 1 for TRUE by default. Keen to just get this fixed ASAP I decided to add that conditional #define for TRUE in gfx.h.

Now that you mentioned this I gave everything a 2nd look and I forgot to include src/gos/gos_options.h in the commit ff01cc0 that you mentioned. Therfore, the GFX_COMPILER_KEIL and GFX_COMPILER_ARMCC macros were not initialized ans as you mentioned they will be treated as a certain default value which resulted in having huge #if problems down the line.

Initializing the GFX_COMPILER_KEIL and GFX_COMPILER_ARMCC macros properly in src/gos/gos_options.h makes this problem going away and everything is working as it should.

Can you please grab the latest master and check whether everything works now as expected for you too?

Sorry for this trouble. Please don't tell this inmarket. I'd prefer to stay alive ;)

~ Tectu

Link to comment
Share on other sites

Thanks for the fix, but I still get warnings on line 60 of gfx.h for the same reason (this time in relation to define the inline keyword). Again, I think this means that the #if statement will always be evaluated as TRUE.

I should mention, if you haven't figured out already, I'm using GCC.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...