🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2888

Re: Undefined #pragmas are evil

#2888
From: Martin J. Maney
Date: Mon, 04 Dec 1995 23:09
45 lines
2698 bytes
David Harmon (source@netcom.com) wrote:
> Any #pragma that is not recognized and supported by an implementation
> _must_ generate a diagnostic!  A pragma that had some important meaning
> when the code was written should not be silently ignored when some new
> compiler doesn't spell it the same way.  This is just plain wrong. 

I must disagree.  If you're using a pragma - any pragma - you are by 
definition working outside of the C++ language.  In this regard a pragma 
is rather like compiler command line options, if you like reasoning by 
analogy.

Besides, pragmas and their behavior have been inherited from Standard C - 
you're complaining during the wrong standization process!

> This would present no problems in code that is ported between different
> compilers if pragmas were properly guarded using symbols that identify the
> compiler, ie.: 

>     #ifdef __BOGUSC__
>     #pragma pack(1)
>     #else
>     #error portability problem
>     #endif

If you want portable code you don't USE pragmas, which are unportable by 
definition.  Conversely, if you must use pragmas, you are either writing 
unportable code or dealing with a non-conforming compiler (of course at 
this moment in time they are all non-conforming owing to lack of a 
standard to which they could conform!).

Even if compilers complained about unrecognized pragmas, what good would 
that do you in general?  There being no standard definitions of pragmas, 
you would have no assurance that compiling without an "unrecognized 
pragma" warning meant that these extra-linguistic instructions had all 
been understood as meaning what you meant them to mean, so what good is 
such "safety"?

> How many pragmas are in your code that do nothing?  How do you know? 

Yep, I know exactly how many there are.  You ought to be able to figure 
out how I know by now, no?  :-)

[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <49vunq$4cc@Venus.mcs.com>
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
References: <9511292357.AA11227@getafix.infosoft.com> <49j043$2ga@engnews1.eng.sun.com> <sourceDIwJ2M.3DL@netcom.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
From: maney@mcs.com (Martin J. Maney)
Newsgroups: comp.std.c++
Subject: Re: Undefined #pragmas are evil
Date: 4 Dec 1995 23:09:57 GMT
Organization: MCSNet Services
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <49vunq$4cc@Venus.mcs.com>
References: <9511292357.AA11227@getafix.infosoft.com> <49j043$2ga@engnews1.eng.sun.com> <sourceDIwJ2M.3DL@netcom.com>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Newsreader: TIN [version 1.2 PL2 (KSD)]
Content-Length: 1851
X-Lines: 41
Originator: clamage@taumet