🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #197

ANSI C spec and GNU C preprocessing

#197
From: Quentin Barnes
Date: Thu, 09 Apr 1992 21:39
47 lines
2352 bytes
I have a few questions about the ANSI C spec (X3.159-1989 section
3.8) and how an ANSI C preprocessor should behave. 

We are using GNU C's preprocessor and as far as I can tell from the
ANSI C spec, it does not follow it on the items below.

1) When a conforming preprocessor encounters a '#' directive which
   is not listed in the preprocessor syntax (ex. '#foo'), what is
   the correct behavior -- declare a fatal error, display a warning,
   or pass it unchanged silently to the compiler?

   GNU C silently passes it on and lets the compiler catch the error.
   Since the spec doesn't say you can do that, I would read that as you
   can't do it, so it would be a fatal error from the preprocessor.
   I can't find a place in the spec that says this though.

2) A conforming preprocessor must output line directives (3.8.4)
   in the format:

	'# line digit-sequence new-line', or 
	'# line digit-sequence "s-char-sequence" new-line'

   The spec allows the general format (3.8.4-15), however, after token
   replacement it must match one of the two above forms.

   Upon entering or exiting a "new" source file, GNU C's preprocessing
   appends the numeral "1" (for entering) or a "2" for exiting.  An
   example line would be:

	# line 34 "myheader.h" 1

   Since this example does not follow the spec, it is not ANSI compliant.
   Correct?

3) An alternate form of the '#line' directive would not use the keyword
   'line'.  For example:

	# 34 "myheader.h"

   This is the default behavior of GNU C's preprocessor unless compiled
   with "OUTPUT_LINE_COMMANDS".  I assume that to be ANSI compliant, the
   preprocessor must generate the 'line' keywoard and the example is
   not compliant.

-- 
Quentin Barnes
qbarnes@urbana.mcd.mot.com | ..!uiucuxc!udc!qbarnes
Technical Details
Message-ID: <1992Apr9.213900.26576@urbana.mcd.mot.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!snorkelwacker.mit.edu!ai-lab!ai.mit.edu!gnulists

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!snorkelwacker.mit.edu!ai-lab!ai.mit.edu!gnulists
From: qbarnes@urbana.mcd.mot.com (Quentin Barnes)
Newsgroups: comp.std.c,gnu.gcc.bug
Subject: ANSI C spec and GNU C preprocessing
Message-ID: <1992Apr9.213900.26576@urbana.mcd.mot.com>
Date: 9 Apr 92 21:39:00 GMT
Followup-To: comp.std.c,gnu.gcc.bug
Organization: Motorola Computer Group, Urbana Design Center
Lines: 47
Approved: info-gnu@prep.ai.mit.edu
Nntp-Posting-Host: neptune.urbana.mcd.mot.com
Apparently-To: gnu-gcc-bug@uunet.uu.net