Should #include <foo.h>; compile?

Dave Rackley drack at titan.tsd.arlut.utexas.edu
Wed Feb 20 01:54:23 AEST 1991


In article <7605 at jhunix.HCF.JHU.EDU> barrett at jhunix.HCF.JHU.EDU (Dan Barrett) writes:

>   Should this program compile?
>
>       #include <stdio.h>;
>       main() {}

>   I have one compiler that complains about the semicolon after the ">", and
>   one that doesn't.  Which is right?  My suspicion is that the program is
>   legal, because a semicolon by itself is an empty statement.  The error
>   message produced by the picky compiler is:
>
>       test.c:1: #include expects "fname" or <fname>

>   Both compilers accept:
>
>       #include <stdio.h>
>       ;
>       main() {}
>

Preprocessor directives are bounded by *line boundaries* not semi-colons.
Per K&R, 2d edition, page 228:  "...any character not otherwise defined is 
taken as a token."  Therefore, it is my opinion that your first example should
not compile (precompile).

--

  DISCLAIMER:  I, hereby, disclaim any disclaimer except this disclaimer.  

+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
| David Rackley                 | Now comes the really weird part...You know  |
| Applied Research Laboratories | the part where I know how to tap dance, but |
| The University of Texas       | only while wearing golf shoes...            |
| Austin, TX.  78758            |        ...Ponderous, man, really ponderous! |
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+



More information about the Comp.lang.c mailing list