I think I've seen
#ifdef __C99__
before, but is there something similar for C++0x?
Thanks.
|
|
0
|
|
|
|
Reply
|
er
|
7/24/2010 4:31:10 PM |
|
er ci wrote:
> I think I've seen
>
> #ifdef __C99__
>
> before, but is there something similar for C++0x?
>
> Thanks.
You the symbol __cplusplus which is defined to be 199711L for
compilers following the 1998 standard, supposedly approved in november
1997.
This symbol will get a new value for C++0x. We just don't know yet
what date it will be - perhaps 201111L ?
Bo Persson
|
|
0
|
|
|
|
Reply
|
Bo
|
7/24/2010 4:46:28 PM
|
|
On 24 juuli, 19:31, er ci <er.ci.2...@gmail.com> wrote:
> I think I've seen
>
> #ifdef __C99__
>
> before, but is there something similar for C++0x?
No compiler supports fully next standard. If you want to write
portable code then avoid all that C++0x for 3-4 years *after* (if it
ever) becomes standard. You will have lot of portability-related fun
without it, that is guaranteed.
|
|
0
|
|
|
|
Reply
|
ISO
|
7/24/2010 4:51:30 PM
|
|
Bo Persson <bop@gmb.dk> wrote:
> You the symbol __cplusplus which is defined to be 199711L for
> compilers following the 1998 standard, supposedly approved in november
> 1997.
>
> This symbol will get a new value for C++0x. We just don't know yet
> what date it will be - perhaps 201111L ?
You could always do an #if (__cplusplus > 199711)
|
|
0
|
|
|
|
Reply
|
Juha
|
7/27/2010 8:06:46 AM
|
|
Actually, what would be ideal would be check whether the compiler flag
-std=c++0x has been set. Can compiler flags be "caught" by a pp macro?
|
|
0
|
|
|
|
Reply
|
er
|
8/17/2010 8:48:05 AM
|
|
On 2010-08-17 04:48:05 -0400, er said:
> Actually, what would be ideal would be check whether the compiler flag
> -std=c++0x has been set. Can compiler flags be "caught" by a pp macro?
The built-in macro __cplusplus is the standard way of checking the C++
version. When C++0x becomes final there will be a new standard value to
reflect 0x support. The standard doesn't say anything about -std=c++0x;
you could ask about that on a GNU forum.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
|
|
0
|
|
|
|
Reply
|
Pete
|
8/17/2010 10:09:47 AM
|
|
On 17 Aug., 10:48, er <er.ci.2...@gmail.com> wrote:
> Actually, what would be ideal would be check whether the compiler flag
> -std=c++0x has been set. Can compiler flags be "caught" by a pp macro?
In this case (GCC invoked with -std=c++0): Yes. See its documentation
(look for a section called "predefined macros" or something along
these lines).
Cheers!
SG
|
|
0
|
|
|
|
Reply
|
SG
|
8/17/2010 10:57:46 AM
|
|
> The built-in macro __cplusplus is the standard way of checking the C++
How exactly, please, as I'm unable to verify this? See below
Under GCC 4.4, with -std=c++0x, under OSX 10.6.4,
#include <iostream>
void f(T&&){} // to be sure that c++0x is enabled,
int main(){
std::cout << "cpp : " << __cplusplus << std::endl; // outputs 1
#if __cplusplus > 199711L
const enable = true;
#else
const enable = false;
#endif
assert( enable ); // fails
return 0;
}
|
|
0
|
|
|
|
Reply
|
er
|
8/18/2010 12:48:41 PM
|
|
Correction:
template<typename T>
> void f(T&&){} // to be sure that c++0x is enabled,
|
|
0
|
|
|
|
Reply
|
er
|
8/18/2010 12:49:40 PM
|
|
Of course, it should be
const bool enable
> =A0 =A0const enable =3D true;
> =A0 =A0#else
> =A0 =A0const enable =3D false;
> =A0 =A0#endif
(Since the code is run from a virtual machine, I have to copy it
manually.)
|
|
0
|
|
|
|
Reply
|
er.ci.2020 (7)
|
8/18/2010 12:52:30 PM
|
|
On 18 Aug., 14:48, er wrote:
>
> Under GCC 4.4, with -std=3Dc++0x, under OSX 10.6.4,
>
> =A0 =A0std::cout << "cpp : " << __cplusplus << std::endl; // outputs 1
>
> =A0 =A0#if __cplusplus > 199711L
> =A0 =A0const bool enable =3D true;
> =A0 =A0#else
> =A0 =A0const bool enable =3D false;
> =A0 =A0#endif
>
> =A0 =A0assert( enable ); // fails
You have been told already that there IS NOT YET an official value the
__cplusplus macro expands to for the next C++ revision. The next
revision is NOT YET DONE.
As for why GCC uses 1 instead of 199711 or how to detect the
experimental C++0x mode, you will find the answers in your compiler's
manual.
http://gcc.gnu.org/onlinedocs/cpp/Predefined-Macros.html
Cheers!
SG
|
|
0
|
|
|
|
Reply
|
s.gesemann (678)
|
8/18/2010 1:13:18 PM
|
|
>
> You have been told already that there IS NOT YET an official value the
Yes, but I'm not testing for an exact value, only a half-range. It was
my understanding from previous comments that this would suffice.
Thanks for the links.
Would this be the relevant section for GCC?
3.7.1 Standard Predefined Macros
__cplusplus
This macro is defined when the C++ compiler is in use. You can use
__cplusplus to test whether a header is compiled by a C compiler or a C
++ compiler. This macro is similar to __STDC_VERSION__, in that it
expands to a version number. A fully conforming implementation of the
1998 C++ standard will define this macro to 199711L. The GNU C++
compiler is not yet fully conforming, so it uses 1 instead. It is
hoped to complete the implementation of standard C++ in the near
future.
So I guess GCC is out for checking C++0x
3.7.3 System-specific Predefined Macros
When the -ansi option, or any -std option that requests strict
conformance, is given to the compiler, all the system-specific
predefined macros outside the reserved namespace are suppressed.
What does reserved namespace mean, here?
|
|
0
|
|
|
|
Reply
|
er
|
8/18/2010 1:30:43 PM
|
|
On 2010-08-18 09:30:43 -0400, er said:
>
> So I guess GCC is out for checking C++0x
>
C++0x doesn't exist yet, so any compiler that claims, by whatever
means, to conform to it is not telling you the truth.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
|
|
0
|
|
|
|
Reply
|
Pete
|
8/18/2010 1:57:34 PM
|
|
On 18 Aug., 15:30, er wrote:
>
> So I guess GCC is out for checking C++0x
In addition to Pete's comment: You gotta try much harder. For example,
look for "C++0x" on that page I linked to. RTFM!
> What does reserved namespace mean, here?
The answer to that is on the same page you quoted the paragraph from!
RTFM!
Cheers!
SG
|
|
0
|
|
|
|
Reply
|
SG
|
8/18/2010 2:19:59 PM
|
|
On Aug 18, 10:19=A0am, SG <s.gesem...@gmail.com> wrote:
> On 18 Aug., 15:30, er wrote:
>
>
>
> > So I guess GCC is out for checking C++0x
>
> In addition to Pete's comment: You gotta try much harder. For example,
Sorry, I wasn't trying too hard anymore, just sharing what caught my
eye as a courtesy to whoever stumbles upon this pb, bec the effort of
finding portable across platforms/compilers solution is not going to
be worth it. For now I'll just manually set a macro to switch between
two implementations, where relevant, one for C03 and the other that
exploits C++0x features.
> look for "C++0x" on that page I linked to. RTFM!
You mean this?
__GXX_EXPERIMENTAL_CXX0X__
This macro is defined when compiling a C++ source file with the
option -std=3Dc++0x or -std=3Dgnu++0x. It indicates that some features
likely to be included in C++0x are available. Note that these features
are experimental, and may change or be removed in future versions of
GCC.
Yes, I took note the comments that C++0x is not a finalized product.
The reason I pursue it to be able to switch between two
implementations (see above) as some people already request C++0x
feature, notwithstanding its incompleteness.
>
> > What does reserved namespace mean, here?
>
> The answer to that is on the same page you quoted the paragraph from!
> RTFM!
OK, got it.
>
> Cheers!
> SG
|
|
0
|
|
|
|
Reply
|
er
|
8/18/2010 2:59:28 PM
|
|
|
14 Replies
347 Views
(page loaded in 0.239 seconds)
Similiar Articles: Checking for whether compiler supports C99 or C++0x - comp.lang ...On 2010-08-17 04:48:05 -0400, er said: > Actually, what would be ideal would be check whether the compiler flag > -std=c++0x has been set. We Wait For Thee: char16_t, char32_t. - comp.lang.c++.moderated ...Checking for whether compiler supports C99 or C++0x - comp.lang ... We Wait For Thee: char16_t, char32_t. - comp.lang.c++.moderated ... Checking for whether compiler ... Bad use of stringstream temporary? - comp.lang.c++Checking for whether compiler supports C99 or C++0x - comp.lang ... Bad use of stringstream temporary? - comp.lang.c++ Checking for whether compiler supports C99 or C++0x ... Gcc binary compatibility chart - comp.unix.programmerChecking for whether compiler supports C99 or C++0x - comp.lang ... Gcc binary compatibility chart - comp.unix.programmer Checking for whether compiler supports C99 or C++ ... Section lines on half section - comp.cad.solidworksChecking for whether compiler supports C99 or C++0x - comp.lang ... See its documentation (look for a section called "predefined macros" or something along these lines ... C++0X explicitly defaulted copy constructors - comp.lang.c++ ...... and I am fine with whatever the compiler ... its limits (it's not possible to check constructors and some operators ... comp.lang.c ... comp.lang.c++ ... intptr_t (C99/C++0X ... Static reflection - a base for runtime reflection? - comp.lang.c++ ...Whether it will be included in the upcoming C++ standards? ... object hierarchies - means for static code checking ... sugar for (2) 2) SFINAE with full expression support ... Where did Fortran go? - comp.lang.fortranIt's not possible to make a compiler which supports C ... later, and I guess it was unclear whether ... It helps the way they check code. I fully support the use of ... size of a derived type containing pointers... - comp.lang.fortran ...... run into compilers that don't support it. The F90 compiler ... so, as noted, I > didn't even check ... when the standard spells it c_loc() ? The question now is whether ... Misuses of RTTI - comp.lang.c++.moderated:-) How you argue here probably depends whether you ... built with a standard (unextended) C++ compiler. ... has not yet been discovered and - absent support for introspection in C ... LSA Disk Sector Read - using int 13h ah 42 (extended read) - comp ...I don't know whether the drive locking will ... uint32_t", and "uint64_t" if your compiler has C99's ... Third, you first need to check if the BIOS supports ah=42h by ... truncate file - comp.lang.c++.moderated... provides a function for your program to determine whether it ... Home: http://JK-Technology.Com FAQs for comp.lang.c ... the lists where they are working on tr2 or c++0x. class definition containing member of own type - comp.lang.c++ ...So the compiler knows everything it needs to know in order ... Not sure why this should be, or whether my definition of ... Misuses of RTTI - comp.lang.c++.moderated... 0X ... Converting number to std::string ("itoa()" ) - comp.lang.c++ ...... int and that is of a size known to the compiler ... Indeed the whole of 7.4.1 in C99 is deeply ... And did you check the location to know whether to use "thousand million" or ... Checking for whether compiler supports C99 or C++0x - comp.lang ...On 2010-08-17 04:48:05 -0400, er said: > Actually, what would be ideal would be check whether the compiler flag > -std=c++0x has been set. Features in Free C++ Compiler Upgrade - C++ Compilers From Comeau ...Now With C99 Language Support!! Check Out libcomo TM! ... it is assumed that the C compiler supports a ... Support for STDC pragmas. Control whether "contracting" expressions ... 7/21/2012 6:09:45 PM
|