[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Patches] stdc-predefs.h breaks heinous preprocessor abuse

	heinous, adj.: utterly reprehensible or evil; odious; abominable

Abuse of CPP has been a Unix tradition since before Imake, and the
stdc-predef.h mechanism, new to GCC 4.8, causes some new problems.

The linux bootloader lilo does some evil source code hackery to make
a common header file, which when fed through "gcc -E -C -traditional
-DLILO_ASM -o common.s common.h", produce a usable nasm assembler source
file.  The preserved comments actually contain assembler source code
which should be ignored by the C compiler, and the opening delimiters,
which are not valid to nasm, are nullified with some trickery.

Anyway, the copyright notices in /usr/include/stdc-predef.h and
/usr/include/bits/predefs.h break this evil trickery, by including
multiline comments whose contents are not valid assembler.

Lilo (24.0) has already implemented a workaround, but it turns out that
there is also a quite painless fix to libc which avoids this problem,
and I'd like to suggest it in case there is some other dusty deck that
has similar problems.

Specifically, if the /* */ comments are preceded by #, then they
consistitute a null preprocessor directive and are stripped even when -C
is in effect.  If a few # characters could be added to those two source
files, they would only produce blank and (if not suppressed with -P)
linemarker lines in the output, which later processing almost certainly
already knows how to deal with.

I realize this is an extreme corner case and the only known regression
is already fixed, but the libc fix is awfully simple.  And cpp is still
retaining -traditional-cpp to cater to such abuses.  I figured I'd at
least put it before you.

(Although a patch is trivial to generate and you're welcome to one, on
reflection I decoded not to include one to avoid the slightest copyright
legal issues.  I *think* it's purely mechanical with zero creative or
artistic content and thus is not subject to to copyright, but letting
you write it seems even safer.  sed -e "s+^/[*]+#&+")
Patches mailing list