C preprocessor failure

Stephen Olsen Stephen_Olsen@mentorg.com
Mon May 15 10:23:00 GMT 2000


Neil,
Take a look at what Henry found.
Thanks Henry, for finding the reference in K&R.
 
Henry Sobotka <sobotka@axess.com>:

Stephen Olsen wrote:
> 
> Could you point me to any specification that says things within
> #ifdef/#endif's must be able to compile even though they are specfically
> excluded from being compiled?

K&R (A12.5 - Conditional Compilation) says the opposite: "Text
controlled by the inactive arms of the conditional is ignored except for
checking the nesting of conditionals."

Henry


Stephen Olsen wrote:
Neil,
Thanks for your quick response.  I still think that it is a bug. 
Could
you
point me to any specification that says things within #ifdef/#endif's
must
be able to compile even though they are specfically excluded from being
compiled?
I tried cc from sunos, Visual C++ 6.0, 4 cross compilers, and an earlier
version of gcc.  All of them succeeded on this test.  Prior
to sending
it
in to you, I handed it over to our compiler guru( we build cross
compilers
here ), and he thought it was a bug.  That is why I submitted
it to you.
As I understand it, everything between an #ifdef/#endif, will either
be
processed, or ignored.  In GCC's case it is both processed and
ignored.
#ifdef's can be used to remove code that is in the process of being
integrated.
One reason that I use #ifdef/#endif's in this manner is to selective
add
and
remove code from being processed.  This could be a large block
of code
with comments.  It may be code that will not compile for some
reason
including
syntax.  That is how I stumbled into this bug.  I was adding
some
functions that
would process these strings.  I put them in temporarily so that
I can
add the
string processing to produce the same string.
One more thought, I also use the C preprocessor one Assembly files.
This
allows me to have one set of #defines, that select which parts of an
assembly
file actually get processed.  Many assemblers have different ways
of
including/
excluding code, so by using the C preprocessor, I have a common way
of
including/excluding code from being processed, regardless of the
assembler
syntax.
I appreciate any and all thoughts on this matter.
Sincerely,
Stephen Olsen
Neil Booth wrote:
> Thanks for your bug report.  It is not a GCC bug, but a bug in
your
> code; see below.
>
> Stephen Olsen wrote:-
>
> > > #ifdef DO_NOT_PROCESS
> > > <input type=\"text\" name=\"designation\">vendor description
> > >
> > > #endif
>
> You cannot put random text in a source file.  Regardless of
the
> setting of DO_NOT_PROCESS, the text in that block must be breakable
> into preprocessing tokens.
>
> The preprocessor does this, as follows:-
>
> <
> input
> type
> =
> \
> "
>
> where the " starts a string but the string never terminates because
> the other quotes are escaped.
>
> Neil.




More information about the Gcc-bugs mailing list