Is this a bug?

The following simple test

#include
#include
#include
using namespace std;

int main()
{
int16_t b = 20;
printf(“%d\n”, b);
}

when complied with

[deleisha@deleisha mytestcode]$ clang++ --version
clang version 3.0 (tags/RELEASE_30/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
[deleisha@deleisha mytestcode]$

produces

[deleisha@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.
[deleisha@deleisha mytestcode]$

telling that c++0x must be enabled.

gcc gives same thing

[deleisha@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@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.

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

Regards
–Dev

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@deleisha mytestcode]$ clang++ --version
clang version 3.0 (tags/RELEASE_30/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
[deleisha@deleisha mytestcode]$

produces

[deleisha@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@deleisha mytestcode]$

telling that c++0x must be enabled.

That seems reasonable, no?

gcc gives same thing

[deleisha@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@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

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

So it means that though c99 has support for stdint.h, c++ make use of only in C++11?

– James

You can include stdint.h in C++, if your library provides it (and doesn’t have a similar trap). It’s just libstdc++'s cstdlib header that is protected against inclusion from C++03. (Stupid restriction IMO, but there you are.) Sebastian

Yes, C++11 is the first C++ standard to be based on C99. The previous
C++ standard came before C99 was published.

You may well be able to use stdint.h from a C++98 compiler as an
extension, but it's not a bug if a C++98 compiler doesn't support C99
facilities.

-- James

thanks James for the good explanation.