Compile error with gcc

Dimitry Andric dim at FreeBSD.org
Mon Feb 17 18:04:48 UTC 2014


On 17 Feb 2014, at 14:55, Julio Merino <jmmv at outlook.com> wrote:
...
> I'm not sure it's going to work.  I think Dimitry mentioned that our libstdc++ should already provide std::vsnprintf, but due to the flags it's built with, it doesn't.  I'm not sure if, due to this, the version check above would do the right thing.

Our libstdc++ config.h is configured that way, because if you run its configure script, it notices that a few long double maths functions are missing.  Then it disables *all* C99 support in libstdc++, including all the stuff we do have, like vsnprintf().

I'm not sure what would be broken if we overrode its automatic detection, and forced libstdc++ to expose C99 functions.  Maybe some other programs would then complain about missing math functions...


>> etc, and if so, what c++ standard was vsnprintf incorporated into? It looks like <some-date> should be 201103L (c++11) (http://en.cppreference.com/w/cpp/io/c/vfprintf ). If so, then the configure.ac tests should instead set the appropriate -std variable (or setting), then test for c++’s existence.
> 
> The point of tests in configure.ac scripts is to _not_ do the above style of checks.  If you are going to use those, then you don't need configure because you can stick those into the code: configure should be checking what the compiler actually does, not what it claims to support.  This way the checks are future-proof and are going to work even for compilers you have not tried yet.
> 
> Note that the check in configure.ac is working just fine and that's not the problem.  The problem is in FreeBSD, where we have a single bconfig.h for the two compilers and the two compilers behave differently in at least one of the detected settings.

It's not the compilers that behave differently, it is the C++ standard library.  If you compile with clang, but use -stdlib=libstdc++, you will encounter the same issue, e.g. std::vsnprintf() will not be available.


> So... we could generate two bconfig.h files, one for each compiler, and use them accordingly... or we could try to eliminate the divergence altogether.  To do the latter, I think it's enough to remove the conditional and leave the code doing:
> 
> namespace std {
> using ::vsnprintf;
> }
> 
> in all cases.  It works in clang but I don't know what the standard has to say in this regard!

You would simply be using the non-std version of vsnprintf().   I don't think this should cause any trouble.

Having said all this, I guess it would be simpler to just patch up our libstdc++ to expose the functions we do have for C99, and not care about what its configure script outputs.

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-testing/attachments/20140217/440a39fc/attachment.sig>


More information about the freebsd-testing mailing list