[ale] Quick gcc question

Fulton Green ale at FultonGreen.com
Thu Jul 22 14:31:13 EDT 2004


On Thu, Jul 22, 2004 at 02:06:32PM -0400, Greg Freemyer wrote:
> I'm trying to compile some code with gcc-3.3.3 that has some multi-line
> strings.
> 
> What gcc argument is needed to enable the multi-line strings?
> 
> >>  Example code that fails
> printf (_("\
> Copy a file, converting and formatting according to the options.\n\
> \n"));
> <<
> 
> I'm getting the error:
> 
> dcfldd.c:326:17: missing terminating " character

A better way to do it, if you have the option of changing the code, is to
write the strings like this:
   printf ("Copy a file.\n"
           "Then use it.\n");
That's the ANSI-standard way of doing things, which is roughly how GCC
compiles by default (the -ansi and -pedantic switches ensure near-100%
checking for ANSI compliance).  Note that the whitespace before the
second line has no bearing on the string literal that GCC creates
internally.

The older way, which is what your code is showing, is indicative of the
Kernighan & Ritchie (or "K&R") syntax used in the initial releases of C,
before the C standards committees came on the scene.  If changing the
code isn't an option, use the -traditional switch.

HTH



More information about the Ale mailing list