http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52764
Bug #: 52764 Summary: Including <cstdint> after <stdint.h> fails to define limit macros Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: bme...@gmail.com Created attachment 27027 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27027 Preprocessed source from g++ -v -save-temps -std=c++0x gcc-stdint.cpp Both <cstdint> and <tr1/cstdint> are implemented by defining __STDC_LIMIT_MACROS, including <stdint.h> and then undefining the macro again. However, if <stdint.h> has already been included (which may occur indirectly via some third-party C library header) then the limit macros do not get defined. I'm not 100% sure this is a bug because the C and C++ standards seem to contradict each other, but here's my reasoning: Both TR1 and C++11 are explicit that <cstdint> will define the limit macros, and C++11 also says "The macros defined by <cstdint> are provided unconditionally. In particular, the symbols __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS (mentioned in footnotes 219, 220, and 222 in the C standard) play no role in C++." TR1 also says that "[<stdint.h>] behaves as if it includes the header <cstdint>, and provides sufficient using declarations to declare in the global namespace all type names defined in the header <cstdint>." I've run into this on GCC 4.6.1, but from a quick look at http://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/include/c_global/cstdint@185951 it looks like this hasn't changed. Command line: g++ -c -std=c++0x gcc-stdint.cpp Output: gcc-stdint.cpp:4:26: error: ‘UINT32_MAX’ was not declared in this scope Output of g++ -v: Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)