Re: Macro redefinition
- From: Tor Rustad <tor_rustad@xxxxxxxxxxx>
- Date: Fri, 31 Aug 2007 21:44:27 +0200
Keith Thompson wrote:
Tor Rustad <tor_rustad@xxxxxxxxxxx> writes:Dave Hansen wrote:
<snip>
Is really the #undef needed in this case? This is a function-likeMy 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.
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, I don't get your point. Doesn't the
"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"
apply?
--
Tor <torust [at] online [dot] no>
.
- Follow-Ups:
- Re: Macro redefinition
- From: Ben Pfaff
- Re: Macro redefinition
- From: Richard Tobin
- Re: Macro redefinition
- References:
- Macro redefinition
- From: Tor Rustad
- Re: Macro redefinition
- From: Dave Hansen
- Re: Macro redefinition
- From: Tor Rustad
- Re: Macro redefinition
- From: Keith Thompson
- Macro redefinition
- Prev by Date: Re: Macro redefinition
- Next by Date: Re: How to force fscanf to find only data on a single input line?
- Previous by thread: Re: Macro redefinition
- Next by thread: Re: Macro redefinition
- Index(es):
Relevant Pages
|