C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-25-2007, 08:43 AM   #1
Registered User
 
Join Date: Jan 2007
Posts: 223
printing macro's at compile time

Is it possible to print macro's with gcc during compile time?

something like

Code:
#define MACRO 4

#pragma warning MACRO
And that gcc says 4 then during compilation
KIBO is offline   Reply With Quote
Old 06-25-2007, 08:50 AM   #2
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,700
What does the manual page tell you?
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Old 06-25-2007, 08:57 AM   #3
Registered User
 
Join Date: Jan 2007
Posts: 223
a lot, but not what im looking for
KIBO is offline   Reply With Quote
Old 06-27-2007, 01:00 AM   #4
Registered User
 
Join Date: Jan 2007
Posts: 223
nobody knows?
KIBO is offline   Reply With Quote
Old 06-27-2007, 03:34 AM   #5
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,492
Since you're looking for compiler-specific behaviour anyway, just try it out.
__________________
All the buzzt!
CornedBee

"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
CornedBee is offline   Reply With Quote
Old 06-27-2007, 04:19 AM   #6
Registered User
 
Join Date: Jan 2007
Posts: 223
jah, of course I tried it but it doesnt work. The original problem why I wanted to do this is solved but I'd still like to know how this is possible, could be handy next time.
gcc docs say lots of things about pragma's, but nothing about printing macro's
KIBO is offline   Reply With Quote
Old 06-27-2007, 04:48 AM   #7
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,492
What does it print?
__________________
All the buzzt!
CornedBee

"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
CornedBee is offline   Reply With Quote
Old 06-27-2007, 06:00 AM   #8
C / C++
 
Join Date: Jan 2006
Location: The Netherlands
Posts: 312
You can add macro's during compiling using this:

Code:
gcc source.c -DMACRO=4
This is the same as:
Code:
#define MACRO 4
It's not the solution to your question, but you can "view" your macro's during the compiling.
__________________
Operating Systems:
- Ubuntu 9.04
- XP

Compiler: gcc
Ideswa is offline   Reply With Quote
Old 06-27-2007, 01:24 PM   #9
Frequently Quite Prolix
 
dwks's Avatar
 
Join Date: Apr 2005
Location: Canada
Posts: 7,698
You can use a sort of if-else construct.
Code:
#define DEBUG 1

#if DEBUG == 1
    #pragma warning Debug mode on.
#elif DEBUG == 0
    #pragma warning Release mode on.
#else
    #pragma warning Invalid DEBUG macro.
#endif
But I'm sure you've already thought of that.
__________________
dwk

Seek and ye shall find. quaere et invenies.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell


Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net

My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
dwks is offline   Reply With Quote
Old 06-28-2007, 08:11 AM   #10
Registered User
 
Join Date: Jan 2007
Posts: 223
all I get is

c:\bla.c(245): warning: ignoring #pragma warning xxx
KIBO is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Clarification on compile time error John_L C Programming 2 12-04-2007 11:59 AM
Military Time Functions BB18 C Programming 6 10-10-2004 01:57 PM
Getting compile time error due to struct member of type int m712 C++ Programming 0 11-29-2002 10:24 PM
compile time errors!!!! devour89 C++ Programming 6 11-18-2002 05:02 PM
Debugging mode selection during compile time YALINI C Programming 1 09-03-2001 09:56 AM


All times are GMT -6. The time now is 06:55 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22