How can I test whether I have libstdc++ of a particular version or better?
Andrew C. Morrow
andrew.c.morrow@gmail.com
Wed Jun 12 23:20:00 GMT 2013
On Wed, Jun 12, 2013 at 7:00 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 12 June 2013 19:36, Andrew C. Morrow wrote:
>>
>> Looking at http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html
>> section 7, I had hoped to be able to write a configure check that
>> included a standard library header, and compared against __GLIBCXX__
>> like follows:
>>
>> #include <vector>
>> // 20110325 is 4.6.0
>> #if defined(__GLIBCXX__) && (__GLIBCXX__ < 20110325)
>> #error
>> #endif
>>
>> However, this won't work: 4.5.4 is newer by date than 4.6.0, so its
>> __GLIBCXX__ value exceeds that of 4.6.0 and so the configure test
>> would pass, even though 4.5.x is not 'newer' than 4.6.0 in terms of
>> feature level.
>
> Right, the macro is pretty much useless, I thought the docs made that
> clear ... indirectly :(
I guess I missed that part.
>
>> Is there some set of values defined by libstdc++ in analogy with
>> __GNUC__, __GNUC_MINOR__ which avoids this date vs. feature ordering
>> issue? Or am I looking at this problem wrong?
>
> You're looking at it wrong, you should check __GNUC__ and
> __GNUC_MINOR__, because you can't use libstdc++ independently of G++
> so just check the G++ version.
Sure you can. The XCode 4.6 provided clang on OS X builds by default
against the Apple provided libstdc++, for instance.
It even works, at least until you try to enable C++11 mode for clang,
at which point things fail in non-obvious ways since libstdc++ 4.2
doesn't even pretend to C++11 awareness.
I hoped to enforce some minimum on the acceptable libstdc++ version
when building with C++11 enabled, probably somewhere around 4.6
vintage, to avoid exactly these sorts of configuration mistakes.
>
> If you want to use libstdc++ independently of G++ then currently
> you're out of luck, someone needs to do the work to make testing those
> macros possible.
Sounds like something worth doing, but of course it wouldn't help in
these instances since any new scheme would not apply in older
releases.
Thanks for your help,
Andrew
More information about the Libstdc++
mailing list