cancel
Showing results for 
Search instead for 
Did you mean: 

Passing parameters from gcc command line

LThal
Associate II

Hi,

I'm attempting to pass a parameter for a conditional compile from the gcc command line to my application. I have two build makefiles, one for debug and one for release. We have some code that's only meant for the release build. So far, so good. If I do a debug build, the eliminated code is grayed out between the "#if (CONFIG_RELEASE)" and the "#endif", which should mean the code was not compiled. However, the code actually IS compiled in (as confirmed by looking at the disassembly window). If I add the line #define CONFIG_RELEASE at the top of the file and compile the project, the correct code is produced. 

I'm using True Studio 9.2.0, and C. Any ideas would be appreciated. Thanks.

Lee Thalblum

3 REPLIES 3

You're not using #ifdef so you always need to define the thing, but also assign it a value, ie 0 or 1

Look at what you're passing in, in most make systems you see the command line, ie with -DCONFIG_RELEASE=1 or -DCONFIG_RELEASE=0

The make file can define its own variables, or pull values from Environment variables.

Sorry not using TrueStudio, just run GNU/GCC via makefiles here.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

Graiying of non-active code is standard Eclipse CDT feature.

Open Eclipse settings and go to indexing options. It can be tweaked there.

-- pa

LThal
Associate II

Thanks, Clive. I tried several different combinations of #if / #ifdef, etc. and -DCONFIG_RELEASE, but I guess I didn't hit the right combination. This did the trick.

Lee