0

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.

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551

3 Answers3

3

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

amit kumar
  • 20,438
  • 23
  • 90
  • 126
1

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
  • 45,516
  • 10
  • 73
  • 79
  • 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 says reinstate Monica Jan 20 '10 at 12:26
0

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

Passing C/C++ #defines to makefile

Community
  • 1
  • 1
Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551