Directives in comments
Reino de Boer
reino at cs.eur.nl
Fri Dec 22 19:46:28 AEST 1989
compata at cup.portal.com (David H Close) writes:
>[...text deleted...] This appears
>to be consistent with K&R (1978), which states on page 207, "These lines
>[beginning with a #] have syntax independent of the rest of the language;
>they may appear anywhere and have effect which lasts (independent of scope)
>until the end of the source program file."
>The following program fragment appears to conform to the rules stated.
> /*
> * Program heading
> #define hdr "Program name"
> * end of heading
> */
> main () { printf(hdr); }
>K&R's assertion that directives "have syntax independent of the rest of
>the language" would appear to me to allow the example.
In K&R Second Edition pp. 228--229, A12. Preprocessing:
3. The program is split into tokens separated by white-space
characters; comments are replaced by a single space. Then
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^(only then)
preprocessing directives are obeyed, and macros (...) are expanded.
Hope this explains -- Reino
--
Reino R. A. de Boer
Erasmus University Rotterdam ( Informatica )
e-mail: reino at cs.eur.nl
More information about the Comp.lang.c
mailing list