Re: Macro redefinition



Tor Rustad <tor_rustad@xxxxxxxxxxx> writes:
Tor Rustad <tor_rustad@xxxxxxxxxxx> writes:
Dave Hansen wrote:
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.
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?

Your replacement lists are different: the first has
generate_source_1, the second has generate_source_2.
--
"It would be a much better example of undefined behavior
if the behavior were undefined."
--Michael Rubenstein
.



Relevant Pages

  • Re: Macro redefinition
    ... has the same number and spelling of parameters, ... The replacement lists were different. ...
    (comp.lang.c)
  • Re: C++ extension problem
    ... warnings for PyArg_ParseTuple). ... Passing incorrect parameters to variable argument lists causes undefined ... Anything can happen under undefined behavior, ... mysterious error messages, erasure of your hard disk, and reversal of ...
    (comp.lang.python)
  • Re: Remove empty strings from list
    ... I have looked at documentation, and how strings and lists work, but I ... remove these empty strings ... print 'discard these: ',item ... As Chris says, you're modifying the list while you're iterating through it, and that's undefined behavior. ...
    (comp.lang.python)