Article View: comp.std.c
Article #4352Re: defined(FOO) in macros
From: Dan Pop
Date: Mon, 13 Nov 1995 11:13
Date: Mon, 13 Nov 1995 11:13
43 lines
1673 bytes
1673 bytes
In <48190c$bak@nyx10.cs.du.edu> colin@nyx10.cs.du.edu (Colin Plumb) writes: >I noticed that a DEC's Alpha compiler breaks on > >host% cat > foo.f <<EOF >#ifndef HAVE_FOO >#define HAVE_FOO defined(FOO) >#endif > >#if HAVE_FOO >#error No, we have FOO >#else >#error Yes, we have no FOO >#endif >EOF >host% cc -migrate foo.c Hey, you created foo.f, but you attempt to compile foo.c :-) >cc: Warning: foo.c, line 5: Spurious token(s) ignored on preprocessor directive line. >#if HAVE_FOO >----^ >cc: Error: foo.c, line 8: #error Yes, we have no FOO >#error Yes, we have no FOO >-^ >cc: Warning: foo.c, line 9: Source file does not contain any declarations. >#endif >------^ > >Now, the second two diagnostics are fine, but is the compiler allowed to >not recognize "defined(FOO)" when it appears as part of a macro expansion? Yes, it is, because you didn't invoke the compiler in ANSI mode. Try to add the -std1 option, which makes it ANSI compliant. Anyway, the compiler is free to emit as many diagnostics as it likes, as long as it translates the source file correctly. Dan -- Dan Pop CERN, CN Division Email: danpop@mail.cern.ch Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
Technical Details
Message-ID:
<danpop.816261239@rscernix>Path:
arc1-ca.pugleaf.net!CERN.ch!rscernix!danpopReferences:
<48190c$bak@nyx10.cs.du.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!CERN.ch!rscernix!danpop From: danpop@mail.cern.ch (Dan Pop) Subject: Re: defined(FOO) in macros X-Nntp-Posting-Host: ues5.cern.ch Message-ID: <danpop.816261239@rscernix> Sender: news@news.cern.ch (USENET News System) Organization: CERN European Lab for Particle Physics X-Newsreader: NN version 6.5.0 #7 (NOV) References: <48190c$bak@nyx10.cs.du.edu> Date: Mon, 13 Nov 1995 11:13:59 GMT