The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM


Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
make multiple line containing a pattern into single line VTAWKVT Shell Programming and Scripting 10 08-07-2008 06:54 AM
to make 2 lines into 1 line using awk cdfd123 Shell Programming and Scripting 2 10-03-2007 04:44 PM
How to make all lines into 1 line? earnstaf UNIX for Dummies Questions & Answers 8 06-13-2007 01:55 PM
Surrounding a chunk of code by #ifdef and #endif xxxaxa Shell Programming and Scripting 6 05-09-2007 10:23 AM
Enable PWD command on anonymous FTP? HiredGun79 IP Networking 9 05-20-2006 11:49 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 12-29-2007
Registered User
 

Join Date: Apr 2006
Posts: 28
how to enable #ifdef macro in the command line of make?

[Keyword] Linux, C++, make, macro

In source code, we used some #ifdef macros. How can I enable #ifdef macro in the command line of "make" (NOTE: I do NOT want to change source code or makefile to define that macro from time to time).

e.g. test.cpp:
...
#ifdef TEST1
// code segment for test1
...
#endif
...
#ifdef TEST2
// code segment for test2
...
#endif
....

Question: How can I enable either macro via command line of make?
e.g. make ????? -> enable TEST1
make ????? -> enable TEST2

Thanks in advance!
Reply With Quote
Forum Sponsor
  #2  
Old 12-29-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Compilers normally use the -D flags

eg

Code:
test.o: test.cpp
     $(CC) $(CFLAGS) -DTEST1 test.cpp -o $@
Reply With Quote
  #3  
Old 12-29-2007
Registered User
 

Join Date: Dec 2005
Posts: 74
if u wish to do it outside makefile
make CFLAGS=-DMACRO

dont forget that inside your make file u are using the CFLAGS macro while compilation
Reply With Quote
  #4  
Old 12-29-2007
Registered User
 

Join Date: Apr 2006
Posts: 28
hi porter & uvrakesh, i got it. thanks a lot.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0