rhl@grendel.Princeton.EDU (Robert Lupton (the Good)) (08/01/90)
The following fails to compile on a sparc running Sun O/S 4.0.3:
#define line LINE
main()
{
#line 1234 "junk.c"
}
as the "#line" is treated as "#LINE" -- does ansi allow this??
Robert
colin@array.UUCP (Colin Plumb) (08/02/90)
In article <1579@idunno.Princeton.EDU> rhl@grendel.Princeton.EDU (Robert Lupton (the Good)) writes: > The following fails to compile on a sparc running Sun O/S 4.0.3: > #define line LINE > > main() > { > #line 1234 "junk.c" > } > as the "#line" is treated as "#LINE" -- does ansi allow this?? Section 3.8.3 Macro Replacement Semantics, paragraph 2: If a # preprocessing token, followed by an identifier, occurs lexically at the point at which a preprocessing directive could begin, the identifier is not subject to macro replacement. This is from the December 7, 1988 draft. Looks like it's illegal. -- -Colin
khera@juliet.cs.duke.edu (Vick Khera) (08/02/90)
In article <384@array.UUCP> colin@array.UUCP (Colin Plumb) writes: >In article <1579@idunno.Princeton.EDU> rhl@grendel.Princeton.EDU (Robert Lupton (the Good)) writes: >> The following fails to compile on a sparc running Sun O/S 4.0.3: >> #define line LINE >> main() >> { >> #line 1234 "junk.c" >> } >> as the "#line" is treated as "#LINE" -- does ansi allow this?? > >Section 3.8.3 Macro Replacement >Semantics, paragraph 2: > > If a # preprocessing token, followed by an identifier, occurs lexically at >the point at which a preprocessing directive could begin, the identifier is >not subject to macro replacement. > >This is from the December 7, 1988 draft. Looks like it's illegal. > -Colin since when did sun claim their sparc compiler under 4.0.3 was ANSI compliant? how can it be illegal if it never intended to follow the new rules? v. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vick Khera (919) 660-6528 Department of Computer Science ARPA: khera@cs.duke.edu Duke University UUCP: ..!{mcnc,decvax}!duke!khera Durham, NC 27706
steve@taumet.com (Stephen Clamage) (08/02/90)
rhl@grendel.Princeton.EDU (Robert Lupton (the Good)) writes:
!#define line LINE
!main()
!{
!#line 1234 "junk.c"
!}
!as the "#line" is treated as "#LINE" -- does ansi allow this??
ANSI C standard section 3.8.3:
"If a # preprocessing token, followed by an identifier, occurs
lexically at the point at which a preprocessing directive could begin,
the identifier is not subject to macro replacement."
In other words, the compiler does not conform to the ANSI standard.
--
Steve Clamage, TauMetric Corp, steve@taumet.com
colin@array.UUCP (Colin Plumb) (08/04/90)
>> In article <1579@idunno.Princeton.EDU> rhl@grendel.Princeton.EDU (Robert Lupton (the Good)) writes: >>> The following fails to compile on a sparc running Sun O/S 4.0.3: ... >>> as the "#line" is treated as "#LINE" -- does ansi allow this?? > In article <384@array.UUCP> colin@array.UUCP (Colin Plumb) writes: >> Looks like it's illegal. In article <21169@duke.cs.duke.edu> khera@cs.duke.edu (Vick Khera) writes: > Since when did Sun claim their sparc compiler under 4.0.3 was ANSI > compliant? How can it be illegal if it never intended to follow the > new rules? Perhaps I phrased it misleadingly, but the question was "does ANSI allow this?" and I answered in the negative. I have no idea if Sun claims their compiler is ANSI-compliant or not. -- -Colin