daven@HPQTDLK.SQF.HP.COM (David Newton) (02/26/90)
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 | +---------------------------------+----------------------------------+