Re: Preprocessor directives ?

From: James Giles (jamesgiles_at_worldnet.att.net)
Date: 02/01/04


Date: Sat, 31 Jan 2004 23:47:21 GMT

Pierre Asselin wrote:
> Richard Edgar <rge21@astro.su.se> wrote:
>> Steve Lionel wrote:
>
>>> Lastly, I'll note that use of such directives will make your code
>>> non-portable, though the extent of the non-portability depends on
>>> exactly what you end up using.
>
>> Minor nitpick.... it needn't. I've used a code which did some makefile
>> magic - run cpp on the source code, and feed the result to the compiler.
>
> Minor nitpic squared, the C preprocessor operates on C-language
> tokens, not characters. Not all legal Fortran constructs are made
> up of legal C tokens, so the preprocessor may choke! But this is
> unusual. Just another little thing to watch for.

In particular, be very careful of character concatenation (//) on
versions of the C preprocessor that have been extended to understand
C++ syntax. In C++, the slash-slash is a comment marker.

-- 
J. Giles


Relevant Pages

  • Re: Preprocessor directives ?
    ... > magic - run cpp on the source code, and feed the result to the compiler. ... the C preprocessor operates on C-language ... tokens, not characters. ... Not all legal Fortran constructs are made ...
    (comp.lang.fortran)
  • Re: The C++ Preprocessor [Re: Boost Workshop at OOPSLA 2004]
    ... > ability to process tokens individually, regardless of the type of preprocessing ... implementing simple domain-specific languages. ... With a C99 preprocessor, and typeof/decltype it could be greatly ...
    (comp.lang.cpp)
  • Re: Paul Grahams teaching style is bad
    ... > operates on the abstract syntax tree produced by parsing the source ... > tokens) with some other tokens. ... You could in theory make a C preprocessor do anything that can ... Lisp's macro facility is out of the box able to easily ...
    (comp.lang.lisp)
  • Re: preprocessor tokenization whitespace?
    ... The C standard does not define the output of the preprocessor as a text ... sequence of tokens and white-space. ... > comment is replaced by one space character. ... > I see nothing in the discussion of macro replacement that would lead to ...
    (comp.lang.c)
  • Re: token pasting
    ... and since gregx6 is a macro, it is replaced with paste2. ... Macro recursion is not allowed in the standard C preprocessor. ... expands into a call to itself, ... Perhaps it was being generous or it regarded "paste2" as 6 tokens. ...
    (comp.lang.c)