Re: #define in a macro definition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux