Author Topic: A little help with Compiler Settings > Defines  (Read 6251 times)

Offline lejar

  • Single posting newcomer
  • *
  • Posts: 4
A little help with Compiler Settings > Defines
« on: September 29, 2012, 01:45:09 pm »
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:

Code
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

  • Guest
Re: A little help with Compiler Settings > Defines
« Reply #1 on: September 29, 2012, 02:03:05 pm »
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.

Offline lejar

  • Single posting newcomer
  • *
  • Posts: 4
Re: A little help with Compiler Settings > Defines
« Reply #2 on: September 29, 2012, 02:12:11 pm »
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

  • Guest
Re: A little help with Compiler Settings > Defines
« Reply #3 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.
« Last Edit: September 29, 2012, 03:02:35 pm by Neil Butterworth »

Offline lejar

  • Single posting newcomer
  • *
  • Posts: 4
Re: A little help with Compiler Settings > Defines
« Reply #4 on: September 29, 2012, 03:26:39 pm »
what build of C::B are you using?
I'm using 10.05 rev 0 on Ubuntu 12.04 x64.

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.
I need it to be different for individual targets, though.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: A little help with Compiler Settings > Defines
« Reply #5 on: September 29, 2012, 03:28:49 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

  • Guest
Re: A little help with Compiler Settings > Defines
« Reply #6 on: September 29, 2012, 04:18:42 pm »
Quote
I'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.

Offline lejar

  • Single posting newcomer
  • *
  • Posts: 4
Re: A little help with Compiler Settings > Defines
« Reply #7 on: October 02, 2012, 09:51:19 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.