This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Deprecating GCC extensions...
- To: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- Subject: Re: Deprecating GCC extensions...
- From: Fergus Henderson <fjh at cs dot mu dot oz dot au>
- Date: Thu, 1 Mar 2001 14:51:00 +1100
- Cc: gcc at gcc dot gnu dot org
- References: <20010228232827.A12658@daikokuya.demon.co.uk>
On 28-Feb-2001, Neil Booth <neil@daikokuya.demon.co.uk> wrote:
> Whilst we're on the topic of deprecating extensions, is there any support
> for deprecating multi-line strings for GCC 3.0?
That particular GCC extension is one that I've only ever seen used by
accident, and often causes portability problems in Mercury code.
So I'm certainly not opposed to it being deprecated.
The way it gets used by accident is that Mercury supports inline C,
where you specify the C code as a Mercury string. People often
forget that in this situation special characters in C string literals
need to be escaped twice, e.g.
:- pragma c_code("
void foo() {
printf(\"hello, world\n\");
}
").
Here instead of \n it should be \\n.
But with the code as is, the Mercury compiler will convert that to
void foo() {
printf("hello, world
");
}
and then unfortunately gcc silently accepts this code, even though it
is not portable. The problem only gets diagnosed when someone tries
to compile the code using a different C compiler.
(We can't use `-pedantic' because in various places we are conditionally
making use of gcc extensions, and there's no way to turn off the warnings
in just those places. [`__extension__' isn't sufficient; I can explain
why not if anyone is interested but that is getting a bit away from the
original topic.])
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.