implicitly continued string constants

Ron Guilmette rfg at NCD.COM
Sun May 19 13:08:11 AEST 1991


In article <1991May15.155113.10624 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
+In article <21455 at ogicse.ogi.edu> morgan at ogicse.cse.ogi.edu (Clark O. Morgan) writes:
+>I noticed the other day that gcc (version 1.39) does not error
+>implicitly continued string constants (e.g., string constants that
+>contain actual newlines)...
+>
+>So here's the question, is the following program legal ANSI C?
+
+No.  Newline is specifically excluded from the list of characters that
+can occur within an ANSI C string literal.
+
+You err in assuming that gcc is an ANSI C compiler, however.  It will try
+to pretend to be one if you give the right magic combination of options,
+but by default it compiles something which is neither old C nor ANSI C.

There is nothing "magic" about it.

Using the -pedantic and -ansi options causes GCC to complain about all
violations of ANSI C (including the one being discussed here).

If you are a pedant, you can install your copy of gcc so that these
options are always on by default.
-- 

// Ron ("Loose Cannon") Guilmette
// Internet: rfg at ncd.com      uucp: ...uunet!lupine!rfg
// New motto:  If it ain't broke, try using a bigger hammer.



More information about the Comp.std.c mailing list