🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4354

Re: defined(FOO) in macros

#4354
From: Colin Plumb
Date: Mon, 13 Nov 1995 12:55
41 lines
1509 bytes
In article <danpop.816261239@rscernix>, Dan Pop <danpop@mail.cern.ch> wrote:
> 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.

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*?
-- 
	-Colin
Technical Details
Message-ID: <487f77$t4s@nyx10.cs.du.edu>
Path: arc1-ca.pugleaf.net!nyx10.cs.du.edu!not-for-mail
References: <48190c$bak@nyx10.cs.du.edu> <danpop.816261239@rscernix>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!nyx10.cs.du.edu!not-for-mail
From: colin@nyx10.cs.du.edu (Colin Plumb)
Newsgroups: comp.std.c
Subject: Re: defined(FOO) in macros
Date: 13 Nov 1995 05:55:03 -0700
Organization: University of Denver, Dept. of Math & Comp. Sci.
Message-ID: <487f77$t4s@nyx10.cs.du.edu>
References: <48190c$bak@nyx10.cs.du.edu> <danpop.816261239@rscernix>
NNTP-Posting-Host: nyx10.cs.du.edu