This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: #define in a macro definition
- From: Brian Dessent <brian at dessent dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 17 Dec 2005 21:58:12 -0800
- Subject: Re: #define in a macro definition
- References: <43A4E5EE.602@micromotive.net>
"Samuel J. Guido" wrote:
> Is it possible with GCC to define an object-like macro within a
> function-like macro, i.e. this is what I am trying to do...
>
> #define MyMacro(a) \
> #define a##Type 55
As far as I can tell ISO C99 forbids this, in §6.10.3.2.1 which says:
"Each # preprocessing token in the replacement list for a function-like
macro shall be followed by a parameter as the next preprocessing token
in the replacement list."
So "#define" in the replacement list would be illegal unless 'define'
was a parameter, in which case it would stringify it.
I don't think what you're trying to do is possible in general with gcc,
but I could be wrong. Maybe if you explain in more detail why you would
need such a thing, someone would be able to offer an alternative.
Brian