views:

52

answers:

3

The title says it all. Thanks.


Background: I develop in Eclipse, and invoke the makfile from Hudson for nightly builds. I would like different values for some #ifdefs depending on whether the code is built in Eclipse or externally from the makefile.

So, something like #ifdef _Eclipse_ would be nice.

+3  A: 

You can yourself define _Eclipse_ or something else for the build you run on Eclipse.

Amit Kumar
Yikes! The bleedin' obvious staring me in the face!!But it's like one of those coding things where you have to think of the negative case.That will work. Thanks, Amit
Mawg
+1  A: 

Why would you want to pollute your code like that? (Clarification: I mean write Eclipse- or Hudson-specific code. Just pick a better macro name and define that in Eclipse or Hudson.)

I'd make seperate targets or otherwise change the build file to pass a -DECLIPSE or -DHUDSON to the preprocessor.

Or pass a parameter to make:
Project Properties -> C/C++ Build -> Build command: make CFLAGS+=-DECLIPSE

Edit: I cannot get += to work from the command line. You might want to try, inside the Makefile:

  ifeq ($(BUILT_BY), eclipse)
    CFLAGS += -D_Eclipse_
    CXXFLAGS += -D_Eclipse_
  endif

and modify eclipse's 'make command' as such: make BUILT_BY=eclipse

aib
plus one for "pollute" - post another comment and I will plus one that too. That's exactly how I feel about it too.And also you other suggestions -I didn't know how to pass -D parameters to make, but never thought of omitting them by default by declaring them only in exlipse.Thnaks
Mawg
A: 

Sorry, folks, but his question is answered by another ...

http://stackoverflow.com/questions/2039643/passing-c-c-defines-to-makefile/2105932#2105932

Mawg