Topic: preprocessor question
Author: Ron Natalie <ron@sensor.com>
Date: Tue, 25 Sep 2001 17:35:14 GMT Raw View
Francis Glassborow wrote:
> so that is a good question
> >
> >My question: does the c / c++ standard
>=20
> note that those are two different standards.
>=20
> > tell anything about how
> >this case should be processed, or in other words: is this a bug
> >or does the standard allow this?
Both the C++ and C standards say that other directives
inside the skipped areas of conditional compilation are ignored.
16.1/6 in C++ says=20
Each directive=92s condition is checked in order. If it=20
evaluates to false (zero), the group that it controls is
skipped: directives are processed only through the name
that determines the directive in order to keep track
of the level of nested conditionals; the rest of the=20
directives=92 preprocessing tokens are ignored, as are the
other preprocessing tokens in the group.
The exact same wording appears in 6.10.1/6 of the C99 standard.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: Johannes Zellner <johannes@zellner.org>
Date: Mon, 24 Sep 2001 20:13:11 GMT Raw View
Hi,
I just recognized that in M$ vc #include directives are
processed before #if directives, e.g. the following code won't
work if the include file is not present:
#if 0
#include "fred.h"
#endif
as the preprocessor first tries to include fred (and then
commenting it out).
My question: does the c / c++ standard tell anything about how
this case should be processed, or in other words: is this a bug
or does the standard allow this?
--
Johannes
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: "Carl Daniel" <carl@pixami.com>
Date: Mon, 24 Sep 2001 21:23:00 GMT Raw View
"Johannes Zellner" <johannes@zellner.org> wrote in message
news:slrn9qu2aj.lrv.johannes@orbital.zellner.org...
> Hi,
>
> I just recognized that in M$ vc #include directives are
> processed before #if directives, e.g. the following code won't
> work if the include file is not present:
>
> #if 0
> #include "fred.h"
> #endif
>
> as the preprocessor first tries to include fred (and then
> commenting it out).
>
> My question: does the c / c++ standard tell anything about how
> this case should be processed, or in other words: is this a bug
> or does the standard allow this?
>
The standard does specify it (I believe), and I don't believe MSVC behaves
as you suggest (I just did a simple test to prove that it doesn't). Perhaps
there's more to your real problem than you posted here?
-cd
PS: The test: simply pase the exact lines you gave above into a file all by
themselves and try to compile it with cl.exe - you'll find that it succeeds,
regardless of the absense of fred.h.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: Francis Glassborow <francis.glassborow@ntlworld.com>
Date: Mon, 24 Sep 2001 22:54:47 GMT Raw View
In article <slrn9qu2aj.lrv.johannes@orbital.zellner.org>, Johannes
Zellner <johannes@zellner.org> writes
>Hi,
>
>I just recognized that in M$ vc #include directives are
>processed before #if directives, e.g. the following code won't
>work if the include file is not present:
>
>#if 0
>#include "fred.h"
>#endif
>
>as the preprocessor first tries to include fred (and then
>commenting it out).
If it actually lexically includes fred.h, it might not comment it out.
E.g. if fred.h was
#endif
#define x
#ifndef x
so that is a good question
>
>My question: does the c / c++ standard
note that those are two different standards.
> tell anything about how
>this case should be processed, or in other words: is this a bug
>or does the standard allow this?
Francis Glassborow
I offer my sympathy and prayers to all those who are suffering
as a result of the events of September 11 2001.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]