error: 'uint8_t' does not name a type
2014-01-05 22:10
976 查看
c++里用了c的代码,确切的说,是引用了c写的x264.h,结果报错了:
都是诸如这样的错误:/x264.h:341:5: error: 'uint8_t' does not name a type
加入
[code] #include <stdint.h>
就好了。
参加:
http://stackoverflow.com/questions/11069108/uint32-t-does-not-name-a-type
感谢下面讨论的还挺复杂的。
'uint32_t' does
not name a type
up vote9down votefavorite 3 | I'm trying to compile a C++ software package that was written in 2007 and I'm getting this error:error: ‘uint32_t’ does not name a type This is happening in 64-bit Ubuntu using g++ 4.5.2. It compiles fine on 64-bit CentOS using g++ 4.1.2. Is there an #includeor a compiler flag that I'm missing? Or, should I use typedefto assign uint32_tto a size_tor maybe an unsigned int? c++
| ||||||||||||||||
comment |
4 Answers
activeoldestvotesup vote14down voteaccepted | You need to include stdint.h[code] #include <stdint.h>
| ||||
comment |
up vote8down vote | You need to #include <cstdint>, but that may not always work. The problem is that some compiler often automatically export names defined in various headers or provided types before such standards were in place. Now, I said "may not always work." That's because the cstdint header is part of the C++11 standard and is not always available on current C++ compilers (but often is). The stdint.h header is the C equivalent and is part of C99. For best portability, I'd recommend using Boost's boost/cstdint.hppheader, if you're willing to use boost. Otherwise, you'll probably be able to get away with #include'ing <cstdint>.
| ||||||||
comment |
up vote2down vote | The other answers assume that your compiler is C++11 compliant. That is fine if it is. But what if you are using an older compiler? I picked up the following hack somewhere on the net. It works well enough for me: [code] #if defined __UINT32_MAX__ or UINT32_MAX #include <inttypes.h> #else typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned long uint32_t; typedef unsigned long long uint64_t; #endif It is not portable, of course. But it might work for your compiler.
| ||
add comment |
up vote1down vote | Add the following in the base.mk file. The following 3rd line is important -include $(TOP)/defs.mk [code]CFLAGS=$(DEBUG) -Wall -W -Wwrite-strings CFLAGS_C=-Wmissing-prototypes CFLAGS_CXX=-std=c++0x LDFLAGS= LIBS= to avoid the #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
|
相关文章推荐
- ndk编译错误:error: 'override' does not name a type
- opencv2.0 源码安装 for x86 make出现error: 'ptrdiff_t' does not name a type 解决
- gem5编译错误:'ptrdiff_t' does not name a type 和 build/ALPHA/python/swig/stats_wrap.o
- CS0234 The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNet' (are you
- 错误:A SPI class of type org.apache.lucene.*** with name 'Whitespace' does not exist.
- `QtValidLicenseForCoreModule' does not name a type 错误的解决
- 两个C++编译异常及解决方法-does not name a type和field `XX' has incomplete type
- 两个C++编译错误及解决办法--does not name a type和field `XX' has incomplete type
- ajax上传图片TypeError: 'append' called on an object that does not implement interface FormData.
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- 编译错误 --- does not name a type和field `XX' has incomplete type
- TypeError: 'dict_keys' object does not support indexing
- Swift Compiler Error Type 'int' does not conform to protocol 'Boolean Type'
- TypeError:'stepUp' called on an object that does not implement interface HTMLInputElement.
- 两个C++编译错误及解决办法--does not name a type和field `XX' has incomplete type
- error: argument of type 'void* (My_Thread::)(void*)' does not match 'void *(*)(void*)'
- string' does not name a type 及命名空间
- NDK error: 'off_t' does not name a type
- 两个C++编译错误及解决办法--does not name a type和field `XX' has incomplete type
- 编译错误 --- does not name a type和field `XX' has incomplete type