This is the mail archive of the gcc@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]

Re: Feature suggestion: allow #ifdefs inside macro args


Jonathan Larmour wrote:
> ISO says in 6.8.3 (Macro replacement): "If there are sequences of
> preprocessing tokens within the list of arguments that would otherwise
> act as preprocessing directives, the behavior is undefined."
> 
> Admittedly it is not clear to me whether this is talking about the macro
> definition, or the usage of the macro.

The C++ standard has exactly the same wording; but it seems
obvious that it refers to macro usage:

  16.3 Macro replacement [cpp.replace]
    10  The sequence of preprocessing tokens bounded
        by the outside-most matching parentheses forms
        the list of arguments for the function-like
        macro. ...
        ... If there are sequences of preprocessing
        tokens within the list of arguments that would
        otherwise act as preprocessing directives, the
        behaviour is undefined.

(Any typos are mine.)

I'd be very surprised if the C and C++ standards differed in
this.

> This is actually quite important, since if it is the latter that makes
> what you are talking about strictly undefined; whereas if it is the former
> it means the standard does not specify it, so we must assume the "normal"
> rules will take effect.

No, it says "undefined", not "unspecified". There's a
difference; if it's undefined, you can format the hard disc; if
it's unspecified, you must _document_ that you'll format the
hard disc. }:-]

Of course you're also allowed to do the sensible thing, and
document it. In this case it would probably be best to just
make it work, according to the principle of least surprise (as
Jeff is wont to say).

-- 
Branko Čibej                 <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
voice: (+386 61) 186 53 49   fax: (+386 61) 186 52 70


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]