I have a project that correctly compiles and runs under g++ 4.8.1 and clang >= 3.3 in c++11 mode. However, when I switch to the experimental -std=c++1y
mode, clang 3.3 (but not g++) chokes on the <cstdio>
header that is indirectly included by way of Boost.Test (so I cannot easily change it myself)
// /usr/include/c++/4.8/cstdio #include <stdio.h> // Get rid of those macros defined in <stdio.h> in lieu of real functions. // ... #undef gets // ... namespace std { // ... using ::gets; // <-- error with clang++ -std=c++1y // ... }
with the following error message:
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/cstdio:119:11: error: no member named 'gets' in the global namespace
On this tutorial on how to set up a modern C++ environment, a similar lookup problem with max_align_t
is encountered. The recommendation there is to use a sed script to surround the unknown symbols with #ifdef __clang__
macros, but that seems a fragile approach.
Setup: plain 64-bit Linux Mint 15 with
g++ (Ubuntu 4.8.1-2ubuntu1~13.04) 4.8.1
Ubuntu clang version 3.3-3~raring1 (branches/release_33) (based on LLVM 3.3)
Questions:
__clang__
macro anywhere near the code in question, and clang in c++11 mode has no trouble at all. std
namespace)? This note in the gets
manpage looks relevant:
ISO C11 removes the specification of gets() from the C language, and since version 2.16, glibc header files don't expose the function declaration if the
_ISOC11_SOURCE
feature test macro is defined.
Probably should be
#if !_ISOC11_SOURCE using ::gets; #endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With