[lexical_cast] Compilation issues with gcc 4.6 -std=c++0x

With 1.48 on 64-bit Windows 7 and gcc 4.6.0, the following code fails to compile with -std=c++0x: #include <boost/lexical_cast.hpp> int main(){} The diagnostics are: C:\Users\Scott\Libraries\Boost\Current/boost/lexical_cast.hpp: In member function 'bool boost::detail::lexical_stream_limited_src<Ch arT, Traits, RequiresStringbuffer>::shl_float(float, wchar_t*)': C:\Users\Scott\Libraries\Boost\Current/boost/lexical_cast.hpp:1210:120: error: there are no arguments to 'swprintf' that depend on a template parameter, so a declaration of 'swprintf' must be available [-fpermissive] C:\Users\Scott\Libraries\Boost\Current/boost/lexical_cast.hpp:1210:120: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) C:\Users\Scott\Libraries\Boost\Current/boost/lexical_cast.hpp: In member function 'bool boost::detail::lexical_stream_limited_src<Ch arT, Traits, RequiresStringbuffer>::shl_double(double, wchar_t*)': C:\Users\Scott\Libraries\Boost\Current/boost/lexical_cast.hpp:1231:122: error: there are no arguments to 'swprintf' that depend on a template parameter, so a declaration of 'swprintf' must be available [-fpermissive] The code compiles fine without -std=c++0x. I don't recall having this problem with earlier releases. Pilot error or library implementation problem? Thanks, Scott

With 1.48 on 64-bit Windows 7 and gcc 4.6.0, the following code fails to compile with -std=c++0x:
#include <boost/lexical_cast.hpp> int main(){}
The diagnostics are:
<snip>
Try compiling with -std=gnu++0x GCC's -std flag is a little confusing: * no -std flag means "C++98 with GNU extensions" * -std=c++98 means "C++98 with no GNU extensions" * -std=c++0x means "C++0x with no GNU extensions" * -std=gnu++0x means "C++0x with GNU extensions" So, if before you were compiling with no -std flag, and now you are compiling with -std=c++0x, then in addition to enabling C++0x features, you are disabling GNU extensions, which I'm guessing wasn't your intention. Now admittedly, Boost should work in the absence of GNU extensions, so there *is* a bug in either Boost or MinGW behind the scenes, but you have a workaround for now. Regards, Nate

On 11/15/2011 6:54 PM, Nathan Ridge wrote:
Try compiling with -std=gnu++0x
That works, thanks.
GCC's -std flag is a little confusing: * no -std flag means "C++98 with GNU extensions" * -std=c++98 means "C++98 with no GNU extensions" * -std=c++0x means "C++0x with no GNU extensions" * -std=gnu++0x means "C++0x with GNU extensions"
So, if before you were compiling with no -std flag, and now you are compiling with -std=c++0x, then in addition to enabling C++0x features, you are disabling GNU extensions, which I'm guessing wasn't your intention.
Bingo, thanks again.
Now admittedly, Boost should work in the absence of GNU extensions, so there *is* a bug in either Boost or MinGW behind the scenes, but you have a workaround for now.
I do, indeed. Thanks once more. Scott
participants (2)
-
Nathan Ridge
-
Scott Meyers