This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: warning: trigraph ... ignored
- To: dl8bcu at gmx dot net
- Subject: Re: warning: trigraph ... ignored
- From: Nix <nix at esperi dot demon dot co dot uk>
- Date: 14 Jun 2000 00:46:00 +0100
- Cc: gcc-patches at gcc dot gnu dot org
- References: <20000613223216.A12898@Marvin.DL8BCU.ampr.org>
Thorsten Kranzkowski <th@Marvin.DL8BCU.ampr.org> writes:
> /usr/src/linux-2.4.0-test1-ac18-work/include/linux/delay.h:19:44: warning: trigraph ??/ ignored
>
> The relevant part of delay.h (linenumbers added):
>
> 19 * specific values can be defined in asm-???/delay.h as an override.
>
> I don't exactly know what trigraphs are, I assume some weird replacement
> expression for unusual characters. But I don't think gcc should warn about
> them in _comments_ !
The Standard says that it must. The relevant phases of compilation are
(paraphrasing from the Standard, not quoting):
1. Do character set conversions; replace trigraph sequences by
their corresponding single-character representations.
2. Elide backslash-newline sequences.
3. [do stuff including replacing comments with whitespace]
Trigraphs are a horrible kludge to let people with sadly deprived
keyboards still type C code. They cause sequences of characters
beginning ?? to be replaced by a single character, like so:
From To
: ??= #
: ??( [
: ??/ \
: ??) ]
: ??' ^
: ??< {
: ??! |
: ??> }
: ??- ~
So that character sequence above
: asm-???/delay.h
expands to
: asm-?\delay.h
This, in particular, is harmless. The problem is that ??/ can expand to
\, and \-newline sequences can separate the parts of a */ that closes a
comment. Thus,
/* This is a valid comment. */
/* And so is this. *\
/
/* But is *this*??/
/
(Yes, it is; it expands to
/* But is *this*/
)
GCC warns about trigraphs because they're sucky, confusing,
brain-damaged, and can do unexpected things. I think warning about them
is entirely appropriate. ;)
--
> ... knowing the alignment of Orcs in AD&D.
Doubleword.
--- David Jacoby and Greg Andrews in the Monastery