3

I want to use c++11 in my project in qt creator.I have tried to add c++11 support by adding one of the following to .pro file :

 CONFIG += c++11

or

 QMAKE_CXXFLAGS += -std=c++11

But none of them works for me, and after adding these to .pro file, the compiler (mingw 4.8) give me a lot of errors like :

C:/Qt/Qt5.3.2/Tools/mingw482_32/i686-w64-mingw32/include/c++/cstdint:48:11: error: '::int8_t' has not been declared using ::int8_t; ^

C:/Qt/Qt5.3.2/Tools/mingw482_32/i686-w64-mingw32/include/c++/cstdint:49:11: error: '::int16_t' has not been declared using ::int16_t; ^

C:/Qt/Qt5.3.2/Tools/mingw482_32/i686-w64-mingw32/include/c++/cstdint:50:11: error: '::int32_t' has not been declared using ::int32_t; ^

C:/Qt/Qt5.3.2/Tools/mingw482_32/i686-w64-mingw32/include/c++/cstdint:51:11: error: '::int64_t' has not been declared using ::int64_t; ^

C:/Qt/Qt5.3.2/Tools/mingw482_32/i686-w64-mingw32/include/c++/cstdint:53:11: error: '::int_fast8_t' has not been declared using ::int_fast8_t;

What is the problem??!

payman
  • 300
  • 2
  • 15

2 Answers2

1

If you are using cstdint, you have to provide need a using for these types.

Insert

using ::int8_t;
using ::int16_t;
using ::int32_t;
using ::int64_t;
using ::int_fast8_t;

(and everything else that's reported missing) into your source file(s), where these errors occur.

There's more on this topic here.

Community
  • 1
  • 1
ollo
  • 24,797
  • 14
  • 106
  • 155
  • Downvote because the answer is wrong. The quote in the question clearly shows that errors are originating from within ``, and exactly in the corresponding `using` statements within that header. With respect to the linked answer; MinGW has one of those many implementations of `` where just the C-header is included, polluting the global namespace, and then lifted into the `std::` namespace using a `using` directive. The problem here is that somehow the C-header does not define those types. I have the same problem 6 years later, and would love a correct answer to the problem. – burnpanck Feb 12 '21 at 11:15
0

The most common case for this error is that you are including standard library headers inside a namespace of you own. (do not do that ;)

example:

namespace my_space {
   #include <cstdint>
}

https://godbolt.org/z/bP7TnWP1s

Jan Wilmans
  • 665
  • 6
  • 10