Re: Macro redefinition
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Fri, 31 Aug 2007 12:09:28 -0700
Tor Rustad <tor_rustad@xxxxxxxxxxx> writes:
Dave Hansen wrote:
<snip>
My question is simply, is the above C code allowed?It's a pretty common idiom in the code I work with. One caveat:
don't
forget to #undef EXPAND_DEF before redefining it.
Is really the #undef needed in this case? This is a function-like
macro, and the re-definition had identical argument list.
C99 6.10.3p2:
An identifier currently defined as an object-like macro shall not
be redefined by another #define preprocessing directive unless the
second definition is an object-like macro definition and the two
replacement lists are identical. Likewise, an identifier currently
defined as a function-like macro shall not be redefined by another
#define preprocessing directive unless the second definition is a
function-like macro definition that has the same number and
spelling of parameters, and the two replacement lists are
identical.
This is a constraint.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- Follow-Ups:
- Re: Macro redefinition
- From: Tor Rustad
- Re: Macro redefinition
- References:
- Macro redefinition
- From: Tor Rustad
- Re: Macro redefinition
- From: Dave Hansen
- Re: Macro redefinition
- From: Tor Rustad
- Macro redefinition
- Prev by Date: Re: Macro redefinition
- Next by Date: Re: Macro redefinition
- Previous by thread: Re: Macro redefinition
- Next by thread: Re: Macro redefinition
- Index(es):
Relevant Pages
|