From: Anh Vo <Anh.V<o@ud...> - 2005-05-20 00:06:41
>>> chicares@... 05/19/05 3:35 PM >>>
On 2005-05-19 14:18 PM, Anh Vo wrote:
<< > I would like to know if "#pragma once" is part of ISO C++
> standard or not.
It is not. The C++98 standard (ISO/IEC 14882) doesn't specify
any particular pragma as standard or even recommended. >>
<< > Obviously, gcc-3.0 or later supports it.
I was going to say it's deprecated by gcc, but I checked first:
| File handling in the preprocessor has been rewritten. GCC
| no longer gets confused by symlinks and hardlinks, and now
| has a correct implementation of #import and #pragma once.
| These two directives have therefore been un-deprecated.
That seems to say it was present but not correct through
gcc-3.3 . >>
That means I do not have do the following every time to make sure only =
once copy is used.
<< But what are you trying to accomplish? Why consider using a
nonstandard feature anyway? Are normal include guards not
adequate for your task? >>
If the above was true, I am more than pleased to get rid of the #pragma =
once and the ifdef macro for all.
From: John Gaughan <john@jo...> - 2005-05-20 02:34:40
Anh Vo wrote:
> That means I do not have do the following every time to make sure
> only once copy is used.
> #ifndef BLA_BLA_BLA
> #define BLA_BLA_BLA
> // ...
This is the standard method used by C and C++ programmers. It is
portable across compilers and is fully documented by the standard.
While #pragma is part of the standard, that is all that is in there: the
#pragma itself. Any options are, by definition, proprietary. Some
options may be the same or similar between compilers, or across
different versions of the same compiler, but there is no guarantee.
> If the above was true, I am more than pleased to get rid of the
> #pragma once and the ifdef macro for all.
The only way to get rid of both would be to stick everything in one big
source code file. One compilation unit, no headers. Otherwise, you
always have the potential of multiple inclusion.
Or you can just live with the #ifdef include guards, which is your