This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Defining a CPP macro that defines a macro
- From: "John \(Eljay\) Love-Jensen" <eljay at adobe dot com>
- To: "Kristis Makris" <kristis dot makris at asu dot edu>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Tue, 7 Nov 2006 13:23:06 -0800
- Subject: RE: Defining a CPP macro that defines a macro
- References: <1162933604.3417.30.camel@syd.mkgnu.net>
Hi Kristis,
To effect the behavior you want, I'd try to do it this way:
#ifdef FIRST_MACRO
#define some_function some_other_function
#endif
Note: for simple function substitution, I use just the identifiers. I don't recommend using a macro function... UNLESS if you need to do something with the parameters, such as change the order around, or remove a parameter, or add a fixed value... well, that's a different can-o'-worms which justifies a macro function.
Now if you are trying to get that to happen *IF-AND-ONLY-IF* the FIRST_MACRO is actually *USED*... then you'll have to go through the code and drop in a #define some_function some_other_function after FIRST_MACRO is used, in each source file. Since you'd have to do that, you may as well just change the function itself, in my opinion - six of one, versus half-dozen of the other.
HTH,
--Eljay