Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwvax!zazen!uakari.primate.wisc.edu!samsung!uunet!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.lang.c Subject: Re: Preprocessor question (is gcc standard)? Message-ID: <1991Feb27.155100.21972@athena.mit.edu> Date: 27 Feb 91 15:51:00 GMT References: <7654@jhunix.HCF.JHU.EDU> Sender: news@athena.mit.edu (News system) Distribution: usa Organization: Massachusetts Institute of Technology Lines: 33 In article <7654@jhunix.HCF.JHU.EDU>, barrett@jhunix.HCF.JHU.EDU (Dan Barrett) writes: |> GCC's preprocessor doesn't like this code: |> |> #include |> #define ARGS (x) |> |> main() |> { |> ... isalpha ARGS ... |> } I believe that GCC is correctly obeying the ANSI C standard here, although it's hard to be sure. K&Rv2 says that an invocation of a macro with arguments must be the name of the macro, followed by optional white space, followed by '('. It doesn't say that the '(' is allowed to be part of another macro that has been expanded. My guess is that the preprocessor is allowed to conclude as soon as it sees a character that is not '(' after the name of the macro, that this isn't a macro invocation. If it couldn't do that, then every time macro substitution happened, the preprocessor would have to check if the first non-whitespace character of the substituted text was '(', and if so, go back and check if the word before the '(' was the name of a macro with arguments. The relevant paragraph from K&Rv2 is the second paragraph on page 230. You should get yourself a copy :-). -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710