问题
The macro __GLIBCXX__
contains the time stamp of libstdc++ releases, e.g., from gcc documentation (https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html)
__GLIBCXX__
The current version of libstdc++ in compressed ISO date format, as an unsigned long. For details on the value of this particular macro for a particular release, please consult the ABI Policy and Guidelines appendix.
I am looking for the values for all releases since the release of 4.9.0 (including releases of smaller versions like 4.8.x).
The documentation of libstdc++ does not seem to provide this information (it only provides the dates up to gcc 4.7.0).
Where can I find the values of __GLIBCXX__
? Does anybody have them?
The ABI Policy and Guidelines appendix (https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html) says
Incremental bumping of a library pre-defined macro. For releases before 3.4.0, the macro is GLIBCPP. For later releases, it's GLIBCXX. (The libstdc++ project generously changed from CPP to CXX throughout its source to allow the "C" pre-processor the CPP macro namespace.) These macros are defined as the date the library was released, in compressed ISO date format, as an unsigned long.
but then only provides the values of the macro up to GCC 4.7.0. Still the day of a particular GCC releases are listed here:
https://gcc.gnu.org/releases.html
but for example for GCC 4.9.1 with release date "July 16, 2014" the ISO date format is 20140716 and the value of __GLIBCXX__
is 20140617 (notice the 7 and 6 have been switched).
回答1:
The information you want is useless anyway, so you should solve your problem a different way.
GCC 4.9.3 was released after GCC 5.3, so it has a later date in that macro, so you can't just do something like:
#if __GLIBCXX__ > 20150422 // GCC 5.1 release
because that would be true for 4.9.3, but that doesn't have all the features that 5.1 has.
Most GNU/Linux distros don't ship official FSF releases either, they build snapshots, which will have the date of the snapshot, which won't be in any list of release dates. And a snapshot from the 5.x branch on a given day will have the same date as a snapshot from the 6.x branch on a given day, so you can't tell them apart.
回答2:
In the interest of answering the original question, here's a hacky command you can execute in your shell to get the list of releases and the value of __GLIBCXX__
for each release (starting with v4.1.0):
svn list "svn://gcc.gnu.org/svn/gcc/tags" | grep -o "gcc_\([^34]_.*\|4_[^0]_.*\)_release" | xargs -n 1 -I {} sh -c "printf \"{}: \" && svn cat svn://gcc.gnu.org/svn/gcc/tags/{}/gcc/DATESTAMP"
The results are:
- 4.1.0: 20060228
- 4.1.1: 20060524
- 4.1.2: 20070214
- 4.2.0: 20070514
- 4.2.1: 20070719
- 4.2.2: 20071007
- 4.2.3: 20080201
- 4.2.4: 20080519
- 4.3.0: 20080305
- 4.3.1: 20080606
- 4.3.2: 20080827
- 4.3.3: 20090124
- 4.3.4: 20090804
- 4.3.5: 20100522
- 4.3.6: 20110627
- 4.4.0: 20090421
- 4.4.1: 20090722
- 4.4.2: 20091015
- 4.4.3: 20100121
- 4.4.4: 20100429
- 4.4.5: 20101001
- 4.4.6: 20110416
- 4.4.7: 20120313
- 4.5.0: 20100414
- 4.5.1: 20100731
- 4.5.2: 20101216
- 4.5.3: 20110428
- 4.5.4: 20120702
- 4.6.0: 20110325
- 4.6.1: 20110627
- 4.6.2: 20111026
- 4.6.3: 20120301
- 4.6.4: 20130412
- 4.7.0: 20120322
- 4.7.1: 20120614
- 4.7.2: 20120920
- 4.7.3: 20130411
- 4.7.4: 20140612
- 4.8.0: 20130322
- 4.8.1: 20130531
- 4.8.2: 20131016
- 4.8.3: 20140522
- 4.8.4: 20141219
- 4.8.5: 20150623
- 4.9.0: 20140422
- 4.9.1: 20140716
- 4.9.2: 20141030
- 4.9.3: 20150626
- 5.1.0: 20150422
- 5.2.0: 20150716
- 5.3.0: 20151204
- 6.1.0: 20160427
- 6.2.0: 20160822
- 6.3.0: 20161221
- 6.4.0: 20170704
- 7.1.0: 20170502
- 7.2.0: 20170814
- 7.3.0: 20180125
Note that these values are from the official releases from the GCC team. If you're using an unofficial release, the values might differ slightly.
回答3:
You can generate a list of possible __GLIBCXX__
values using the SVN release listing as source:
svn list --xml 'https://gcc.gnu.org/svn/gcc/tags' \
| grep '>gcc.*release' -A4 \
| grep 'name\|date' \
| sed -e 's/<[^>]\+>//g' -e 's/T.*$//' -e 's/-//g' \
-e 's/gcc_\|_release//g' \
| paste - -
A similar list, but more free-form and annotate with branching ascii art is maintained by the GCC team:
https://gcc.gnu.org/develop.html#timeline
Note that multiple release branches are active in parallel, cf e.g. the 4.8 and 4.9 branches:
4_8_0 20130322
4_8_1 20130531
4_8_2 20131016
4_8_3 20140522
4_8_4 20141219
4_8_5 20150623
4_9_0 20140422
4_9_1 20140716
4_9_2 20141030
4_9_3 20150626
4_9_4 20160803
Thus, unfortunately, you can't use a single date as simple cut-off value to determine a certain release.
Of course, you can auto-generate some helper macros from this list. Say - you need some workaround for the 4.8 GLIBCXX release (as used by GCC and different clang versions) then you could define a helper macro like this (after including some STL header):
#if __GLIBCXX__ == 20130322 \
|| __GLIBCXX__ == 20130531 \
|| __GLIBCXX__ == 20131016 \
|| __GLIBCXX__ == 20140522 \
|| __GLIBCXX__ == 20141219 \
|| __GLIBCXX__ == 20150623
#define HAVE_GLIBCXX_4_8 1
#else
#define HAVE_GLIBCXX_4_8 0
#endif
If you are just interested in the major version and only need to support releases newer than GCC 7 than you can also use the _GLIBCXX_RELEASE
macro.
来源:https://stackoverflow.com/questions/37118114/value-of-glibcxx-for-each-libstdc-release