This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: #define in a macro definition


"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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]