Article View: comp.std.c
Article #4370Re: defined(FOO) in macros
From: Dan Pop
Date: Wed, 15 Nov 1995 11:43
Date: Wed, 15 Nov 1995 11:43
50 lines
1689 bytes
1689 bytes
In <487f77$t4s@nyx10.cs.du.edu> colin@nyx10.cs.du.edu (Colin Plumb) writes:
>Okay, okay, if I can't DWIM with this audience, try the following:
>
>host% cat >foo.c <<EOF
>#define FOO 1
>
>#ifndef HAVE_FOO
>#define HAVE_FOO defined(FOO)
>#endif
>
>#if HAVE_FOO
>/* I believe the following to be a Strictly Conforming program. */
>#include <stdio.h>
>#include <stdlib.h>
>int main(void) {
> return puts("Hello, world!") < 0 ? EXIT_FAILURE : 0;
>}
>#else
>#error Huh, we have no FOO?
>#endif
>EOF
>host% cc -migrate -std1 foo.c
>cc: Warning: foo.c, line 7: Spurious token(s) ignored on preprocessor directive line.
>#if HAVE_FOO
>----^
>cc: Error: foo.c, line 15: #error Huh, we have no FOO?
>#error Huh, we have no FOO?
>-^
>cc: Error: foo.c, line 16: Source file does not contain any declarations.
>#endif
>------^
>host%
>
>How is *that*?
Time to upgrade your compiler:
ues5:~/tmp 5> uname -a
OSF1 ues5.cern.ch V3.2 17 alpha
ues5:~/tmp 6> cc -migrate -std1 foo.c
ues5:~/tmp 7> ./a.out
Hello, world!
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.816435834@rscernix>Path:
arc1-ca.pugleaf.net!CERN.ch!rscernix!danpopReferences:
<48190c$bak@nyx10.cs.du.edu> <danpop.816261239@rscernix> <487f77$t4s@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.816435834@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> <danpop.816261239@rscernix> <487f77$t4s@nyx10.cs.du.edu> Date: Wed, 15 Nov 1995 11:43:54 GMT