This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Deprecating GCC extensions...


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]