🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Pierre Willard Thu, 03 Sep 1992 19:06
#define multi-lined strings
#1059
Author: Pierre Willard
Date: Thu, 03 Sep 1992 19:06
89 lines
2590 bytes
There is a bug in the preprocessor of gcc 2.1 and 
gcc-1.40.

It is possible to write a #define which will generate several C lines
in the preprocessed file. This makes bad line numbers. This happens
when using a multi-lined string in a #define.

I guess the fix is for cpp to translate a mutli-lined string in a
#define into a one line string (ie use '\n').

In the example below, cpp should output :

"just\na little\nmulti-lined\nstring"; foo(x)

The following demonstrates the problem.

psi:/usr2/pierre:cat pw.c

#define FOOO x = "just
a little
multi-lined
string"; foo(x)

void
foo(char *x)
{

}

main()
{
char *x;

  FOOO;
}
psi:/usr2/pierre:gcc -E pw.c
# 1 "pw.c"






void
foo(char *x)
{

}

main()
{
char *x;

  x = "just
a little
multi-lined
string"; foo(x) ;
# 18 "pw.c"
}
psi:/usr2/pierre:gcc -v -g -O -o pw pw.c
Reading specs from /usr/local/lib/gcc-lib/sun4/2.1/specs
gcc version 2.1
 /usr/local/lib/gcc-lib/sun4/2.1/cpp -lang-c -v -undef -D__GNUC__=2 -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix -D__OPTIMIZE__ -g pw.c /usr/tmp/cca24573.i
GNU CPP version 2.1 (sparc)
 /usr/local/lib/gcc-lib/sun4/2.1/cc1 /usr/tmp/cca24573.i -quiet -dumpbase pw.c -g -O -version -o /usr/tmp/cca24573.s
GNU C version 2.1 (sparc) compiled by GNU C version 2.1.
 as -o pw.o /usr/tmp/cca24573.s
 /usr/local/lib/gcc-lib/sun4/2.1/ld -e start -dc -dp -o pw /lib/crt0.o -L/usr/local/lib/gcc-lib/sun4/2.1/ -L/usr/local/lib/ pw.o -lgcc -lc -lg -lgcc
psi:/usr2/pierre:gdb pw
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.5, Copyright 1992 Free Software Foundation, Inc...
(gdb) b main
Breakpoint 1 at 0x22cc: file pw.c, line 17.
(gdb) run
Starting program: /usr2/pierre/pw 

Breakpoint 1, main () at pw.c:17
17	  FOOO;
(gdb) n
Line number 20 out of range; pw.c has 18 lines.
(gdb) quit
The program is running.  Quit anyway? (y or n) y
psi:/usr2/pierre:

Let me know your comments.
Regards
Pierre Willard
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads