[cfe-dev] Is this a bug?

James Dennett james.dennett at gmail.com
Mon Jul 2 00:53:58 PDT 2012


On Mon, Jul 2, 2012 at 12:05 AM, Devchandra L Meetei <dlmeetei at gmail.com> wrote:
> The following simple test
>
> #include<iostream>
> #include<cstdio>
> #include<cstdint>

cstdint is part of C++11.

> using namespace std;
>
> int main()
> {
>     int16_t b = 20;
>     printf("%d\n", b);
> }
>
> when complied with
>
>>[deleisha at deleisha mytestcode]$ clang++ --version
>>clang version 3.0 (tags/RELEASE_30/final)
>>Target: x86_64-unknown-linux-gnu
>>Thread model: posix
>>[deleisha at deleisha mytestcode]$
>
> produces
>
> [deleisha at deleisha mytestcode]$ clang++ stdint_test.cpp
> In  file included from stdint_test.cpp:3:
> In file included from
> /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/cstdint:34:
> /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/c++0x_warning.h:31:2:
> error: #error This file requires compiler and library support for the
> upcoming ISO C++ standard, C++0x.
>       This support is currently experimental, and must be enabled with the
> -std=c++0x or -std=gnu++0x compiler options.
> #error This file requires compiler and library support for the upcoming \
>  ^
> 1 error generated.

This error message is generated by libstdc++ when you include cstdint
with a compiler that doesn't support it.  You're using an old enough
version of libstdc++ that it doesn't refer to the C++11 standard by
its final name.

> [deleisha at deleisha mytestcode]$
>
> telling that c++0x must be enabled.

That seems reasonable, no?

> gcc gives same thing
>
>>[deleisha at deleisha mytestcode]$ g++ stdint_test.cpp
>>In file included from
>> /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/cstdint:35,
>  >                from stdint_test.cpp:3:
>>/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/c++0x_warning.h:31:2:
>> error: #error This file requires compiler and library support for the
>> upcoming ISO C++ standard, C++0x. This support is currently >experimental,
>> and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
>>[deleisha at deleisha mytestcode]$
>
>
> May  be this is because, in my setup, clang is using gcc headers, but
> clang++ 's (#error line in italics above) is confusing.

That's libstdc++'s error message.

> BUT my major worry is that, I am hoping that stdint.h are part c99 std. So
> is warning seems to irrelevant.

cstdint is part of C++11.  The previous C++ standard did not include
C99 headers or features.

-- James




More information about the cfe-dev mailing list