Article View: comp.std.c++
Article #3356Re: #warning
From: Steve Clamage
Date: Tue, 20 Feb 1996 21:13
Date: Tue, 20 Feb 1996 21:13
48 lines
2636 bytes
2636 bytes
In article kgn@mulga.cs.mu.OZ.AU, fjh@munta.cs.mu.OZ.AU (Fergus Henderson) writes:
>clamage@Eng.Sun.COM (Steve Clamage) writes:
>>
>>Yes, you forgot to say how it differs from #error, which is already in the
>>draft (and in Standard C). The description of #error says only that it
>>"causes the implementation to produce a diagnostic message that includes
>>the specified sequence of preprocessing tokens."
>
>Isn't this a bug in the standard? Doesn't this mean that
>
> #error foobar
> int main() { return 0; }
>
>is a strictly conforming program? Yet no compiler I know of will accept it!
It is a strictly conforming program (although we don't use that terminology
in the C++ standard). The implementation must tell you what the effect
of #error is. If the effect is to abort compilation, that is allowed.
>Surely the semantics specified for #error should say that it has the effect
>of making the translation unit ill-formed.
Why? You can write ill-formed code if you want to. For example:
#if undesirable_condition
this phrase should not be seen by the compiler
#endif
The #error directive is part of the language, and I think it would be a
contradiction in terms to say that a valid language construct is ill-formed.
"Everyone knows" that the #error directive is supposed to halt compilation,
but for reasons I outlined earlier there isn't a good way (or at least
no one has found a way) to say so in the standard, given the basic
assumptions about what the C++ standard is supposed to be. Other languages
may define a particular environment where you can talk about compilation,
or linking, or known formats of data types, etc, but we have chosen not
to do so with C++.
---
Steve Clamage, stephen.clamage@eng.sun.com
[ To submit articles: Try just posting with your newsreader.
If that fails, use mailto:std-c++@ncar.ucar.edu
FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID:
<4gdcvn$cqv@engnews1.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageReferences:
<4g91rh$kgn@mulga.cs.mu.OZ.AU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: clamage@Eng.sun.com (Steve Clamage) Newsgroups: comp.std.c++ Subject: Re: #warning Date: 20 Feb 1996 21:13:15 GMT Organization: Sun Microsystems Inc. Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <4gdcvn$cqv@engnews1.Eng.Sun.COM> References: <4g91rh$kgn@mulga.cs.mu.OZ.AU> Reply-To: clamage@Eng.sun.com NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: taumet.eng.sun.com Content-Length: 1735 X-Lines: 41 Originator: clamage@taumet