News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

A little help with Compiler Settings > Defines

Started by lejar, September 29, 2012, 01:45:09 PM

Previous topic - Next topic

lejar

I have several build targets that reference the same code and I would like certain build targets to not compile a section of the shared code. (The server target should compile everything and the client target should not compile a specific section of code.) Under the build options for the server target, I've gone to compiler settings > #defines and entered the following:

Quote"SERVERTOPOLOGY=1"

My code looks like this:

general code
#if SERVERTOPOLOGY==1
 code for the server
#endif
more general code


Unfortunately, I can't seem to get this to work. The server target does not compile the code inside of the #if statement. I've also tried single quotes, and leaving the quotes away for the define. I've also tried replacing the #if SERVERTOPOLOGY==1 part with #ifdef SERVERTOPOLOGY to no avail.

Perhaps someone can give me a little insight into my problem?

zabzonk

The define should not be in quotes. If you do:

SERVERTOPOLOGY=1

then both the #ifdef and #if directives should work. Oh, and make sure you are defining it it for the right target.

lejar

Thanks for the input, Neil. I had tried it without the quotes. Checking the target proved interesting, though. I am using a virtual target to build my targets in one click. When I build each target individually, the defines work. When I build using my virtual target, the defines do not work. Is this a bug or a feature?

zabzonk

#3
I've never used virtual targets before, but I just tried it and it seems to work OK - what build of C::B are you using? Also, you can define it for all real targets by adding it to the top-level target in the tree on the left of the Project build options dialog.

lejar

Quote from: Neil Butterworth on September 29, 2012, 02:50:58 PM
what build of C::B are you using?
I'm using 10.05 rev 0 on Ubuntu 12.04 x64.

Quote from: Neil Butterworth on September 29, 2012, 02:50:58 PMAlso, you can define it for all real targets by adding it to the top-level target in the tree on the left of the Project build options dialog.
I need it to be different for individual targets, though.

Jenna

Quote from: Neil Butterworth on September 29, 2012, 02:50:58 PM
I've never used virtual targets before, but I just tried it and it seems to work OK - what build of C::B are you using? Also, you can define it for all real targets by adding it to the top-level target in the tree on the left of the Project build options dialog.
There is no toplevel target.
I guess what you mean is the project itself.

Note:
there is a dropdownlist for each target to chose. which settings should be used and whether they should be prepended or appended to the project settings.

zabzonk

QuoteI'm using 10.05 rev 0 on Ubuntu 12.04 x64.

Might be time to upgrade to a recent nightly. Though I have no idea if this is a bug that has been fixed, it does seem to work for me - I'm using SVN 8024 on Windows.

lejar

Quote from: Neil Butterworth on September 29, 2012, 04:18:42 PM
Might be time to upgrade to a recent nightly. Though I have no idea if this is a bug that has been fixed, it does seem to work for me - I'm using SVN 8024 on Windows.

Sorry for taking so long to answer. I switched to SVN 8150 and the problem is fixed.