Compile error with gcc

Julio Merino jmmv at outlook.com
Mon Feb 17 13:57:08 UTC 2014


On Feb 17, 2014, at 01:07 , Garrett Cooper <yanegomi at gmail.com> wrote:
> 
> Thanks Dimitry for the input.
> 
> Should this check be done with…
> 
> #if defined(__cplusplus) && __cplusplus >= <some-date>

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.

> 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.

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!

(FYI: I fixed the immediate problem in HEAD by changing bconfig.h to #undef the setting -- just as we had been doing since the initial import of ATF.)


More information about the freebsd-testing mailing list