Clang> = 3.3 in C ++ 1y mode cannot parse the <cstdio> header

I have a project that compiles and runs correctly under g ++ 4.8.1 and clang> = 3.3 in C ++ 11. However, when I switch to the experimental mode -std=c++1y , clang 3.3 (but not g ++) throttles the <cstdio> header, which is indirectly enabled using 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/../../../../ includes / C ++ / 4.8 / cstdio: 119: 11: error: no member with the name 'gets' in the global namespace

In this tutorial on how to set up a modern C ++ environment, there is a similar search problem with max_align_t . The recommendation is to use a sed script to surround unknown characters with #ifdef __clang__ macros, but this seems like a fragile approach.

Setup: Simple 64-bit Linux Mint 15 with

g ++ (Ubuntu 4.8.1-2ubuntu1 ~ 13.04) 4.8.1

Ubuntu clang version 3.3-3 ~ raring1 (branch / release_33) (based on LLVM 3.3)

Questions :

  • What causes this erorr? There is no __clang__ macro anywhere near this code, and clang in C ++ 11 mode has no problems at all.
  • Is this a language issue (does C ++ 14 say anything else besides C ++ 11 on how to import C-compatible characters from global to std )?
  • Do I need to change something using my included paths? (I use CMake to automatically select header paths and switching modes inside CMakeLists.txt)
  • Does clang have a switch to solve this problem?
+41
c ++ c ++ 11 header clang c ++ 14
Jul 21 '13 at 18:17
source share
1 answer

This note in the gets help page looks relevant:

ISO C11 removes the gets () specification from C, and since version 2.16, glibc header files do not expose a function declaration if the _ISOC11_SOURCE test macro is _ISOC11_SOURCE .

Probably should be

 #if !_ISOC11_SOURCE using ::gets; #endif 
+23
Jul 21 '13 at 20:25
source share
— -



All Articles