[Developers] does anybody understand __cplusplus
John Sibert
sibert at hawaii.edu
Fri Dec 14 16:57:17 PST 2012
The __cplusplus macro used as follows in the threaded protoype version
of the autodif library.
#if (__cplusplus > 199711L)
#define __ADMBTHREAD__ __thread
#else
#define __ADMBTHREAD__
#endif
I got curious about it since I always thought is should be 1. However,
various internet disinformation yields confusing "epertize" on the
interpretation of of this macro. Here is one explanation.
>
> __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.
>
However larger values, indicating more recent and standard-conforming
(?) versions of the compiler. These are apparently intend for arm
devices? So __ADMBTHREAD__ is only defined for arm compilers?
I did a little experiment on a the new admb workstation (katsuo) and on
my 4 year old laptop (kolea). Apparently gcc 4.4 is not up to standard.
(I'm trying to install 4.7.2 on kolea, but that is a different tale of woe.)
tagest: tag movement estimation procedure; ADMB implementation.
Source directory: /home/jsibert/movemod/25
SVN revision number: 3009
Compiler: Gnu C++4.7.2 on katsuo
Architecture: 64 bits
Operating system: linux-gnu
Safe ADMB libraries, Version
starting time: Wed Dec 31 14:00:00 1969
line 1233, file linux-gnu/tagest.cpp, __cplusplus = 199711
line 1235, file linux-gnu/tagest.cpp, sysconf(_SC_NPROCESSORS_CONF) =
12, sysconf(_SC_NPROCESSORS_ONLN) = 12
tagest: tag movement estimation procedure; ADMB implementation.
Source directory: /home/jsibert/movemod/25
SVN revision number: 3029M
Compiler: Gnu C++4.4.3 on kolea
Architecture: 64 bits
Operating system: linux-gnu
Safe ADMB libraries, Version
starting time: Wed Dec 31 14:00:00 1969
line 1236, file linux-gnu/tagest.cpp, __cplusplus = 1
line 1238, file linux-gnu/tagest.cpp, sysconf(_SC_NPROCESSORS_CONF) = 2,
sysconf(_SC_NPROCESSORS_ONLN) = 2
Have a nice weekend,
John
--
John Sibert
Emeritus Researcher, SOEST
University of Hawaii at Manoa
Visit the ADMB project http://admb-project.org/
More information about the Developers
mailing list