🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2902

GNU cpp behaviour with string constants under -traditional

#2902
From: David Newton
Date: Mon, 26 Feb 1990 15:37
53 lines
2292 bytes
If the GNU cpp is run as follows:

	cpp -traditional test.c

where test.c contains:

 |
 |#ifndef FRED
 |"abc
 |"
 |#endif
 |

the following error message is produced:

   test.c:1: unterminated #if conditional

If cpp is run without "-traditional" the input is accepted.

K&R explicitly states that a newline can not appear in a string constant. I
couldn't find any statement in their section on ANSI that ANSI behaviour
was to be different. Is the above correct behaviour for cpp ? What makes me
doubt it is that a similar string constant outside of a #ifdef/#endif is
passed by cpp without complaint. To be consistent one or the other should
change. gcc itself accepts string constants with embedded newlines without
complaint.

What I am really trying to do is place assembly language between
#ifdef/#endif. For example:

#ifdef FRED
 asm( "
    mov r1,r2
    clr r0
    ....etc... 
")
#endif

With the above behaviour ( we need -traditional to obtain the correct
headers ), assembly language sequences within a #ifdef/#endif fail. Escaped
newlines can't be used, because the assembler won't accept the single line
input. The only other solution of having an "asm()" per instruction seems
clumsy. Can anyone suggest an alternative to this ?


+---------------------------------+----------------------------------+
| David Newton                    | HPDESK: David Newton/HP1400/B1   |
| Hewlett Packard Ltd             | ARPA:   daven@hpsqf.sqf.hp.com   |
| Queensferry Telecomms Division  |                                  |
| South Queensferry               | UUCP:   ..!hplabs!hpsqf!daven    |
| West Lothian                    | JANET:  daven@hpqtdla.hp.co.uk   |
| Scotland EH30 9TG.              | PHONE:  +44-31-331-7234          |
+---------------------------------+----------------------------------+
Technical Details
Message-ID: <9002261537.AA19471@hpqtdlk.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!telly!philmtl!uunet!bu.edu!snorkelwacker!tut.cis.ohio-state.edu!HPQTDLK.SQF.HP.COM!daven

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!philmtl!uunet!bu.edu!snorkelwacker!tut.cis.ohio-state.edu!HPQTDLK.SQF.HP.COM!daven
From: daven@HPQTDLK.SQF.HP.COM (David Newton)
Newsgroups: gnu.gcc.bug
Subject: GNU cpp behaviour with string constants under -traditional
Message-ID: <9002261537.AA19471@hpqtdlk.HP.COM>
Date: 26 Feb 90 15:37:05 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 53