本文介绍了关于c/c ++的奇怪的编译错误:"#define“永远不会工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
今天我错过了一个奇怪的编译错误:
g ++ -DHAVE_CONFIG_H -I. -I .. -I ../Common -I ../FS -I ../IO -I ../SequenceFile -I ../Compress -I ../Serialization -I ../../api- I ../../../../../build/c ++/Linux-i386-32/include -I ../../../../../src/c ++/libhdfs- I ../../../../../src/c ++/utils/api -I/home/had/jdk1.6.0_21/include -I/home/had/jdk1.6.0_21/include/linux -g -O2 -MT BinaryConnection.o -MD -MP -MF .deps/BinaryConnection.Tpo -c -o BinaryConnection.o BinaryConnection.cc
在BufferParam.hh:22:0中包含的文件中,
来自KeyValueElement.hh:24,
来自InternalReader.hh:23,
来自Merger.hh:22,
来自OrderedIterator.hh:24,
来自ReduceInputReader.hh:24,
来自TaskContextImpl.hh:26,
来自BinaryConnection.hh:23,
来自BinaryConnection.cc:19:
Def.hh:40:31:错误:未在此范围内声明"UINT64_MAX"
Def.hh:41:31:错误:此范围内未声明"INT64_MAX"
Def.hh:42:31:错误:在此范围内未声明"INT64_MIN"
Def.hh:43:31:错误:未在此范围内声明"UINT32_MAX"
Def.hh:44:31:错误:在此范围内未声明"INT32_MAX"
Def.hh:45:31:错误:在此范围内未声明"INT32_MIN"
Def.hh:46:31:错误:未在此范围内声明"UINT16_MAX"
Def.hh:47:31:错误:此范围内未声明"INT16_MAX"
Def.hh:48:31:错误:在此范围内未声明"INT16_MIN"
Def.hh:49:31:错误:未在此范围内声明"UINT8_MAX"
Def.hh:50:31:错误:在此范围内未声明"INT8_MAX"
Def.hh:51:31:错误:在此范围内未声明"INT8_MIN"
这里是Def.hh的内容:
18
19 #ifndef __DF_DEF_H__
20#定义__DF_DEF_H__
21//在stdint.h中启用宏定义
22 #ifndef __STDC_LIMIT_MACROS
23#定义__STDC_LIMIT_MACROS 1
24#undef _STDINT_H
25 #endif
26
27 #include < stdint.h > 跨度>
28 #include < stdlib.h > 跨度>
29 #include < string.h > 跨度>
30 #include < malloc.h > 跨度>
31///#include"ul_def.h"
32//常见类型的定义
33
34 typedef签名的char char8;
35 typedef unsigned char u_char8;
36
37 const uint64_t MAX_U_INT64 = UINT64_MAX;
38 const int64_t MAX_INT64 = INT64_MAX;
39 const int64_t MIN_INT64 = INT64_MIN;
40 const uint32_t MAX_U_INT32 = UINT32_MAX;
41 const int32_t MAX_INT32 = INT32_MAX;
42 const int32_t MIN_INT32 = INT32_MIN;
43 const uint16_t MAX_U_INT16 = UINT16_MAX;
44 const int16_t MAX_INT16 = INT16_MAX;
45 const int16_t MIN_INT16 = INT16_MIN;
46 const uint8_t MAX_U_INT8 = UINT8_MAX;
47 const int8_t MAX_INT8 = INT8_MAX;
48 const int8_t MIN_INT8 = INT8_MIN;
49
50 #endif//#ifndef __DF_DEF_H__
51
宏似乎使"stdint.h"始终被包括在内,而UINT64_MAX及其兄弟"始终被定义;但是为什么g ++会抱怨这些错误?方案
Today I missed a strange compiled error:
g++ -DHAVE_CONFIG_H -I. -I.. -I../Common -I../FS -I../IO -I../SequenceFile -I../Compress -I../Serialization -I../../api -I../../../../../build/c++/Linux-i386-32/include -I../../../../../src/c++/libhdfs -I../../../../../src/c++/utils/api -I/home/had/jdk1.6.0_21/include -I/home/had/jdk1.6.0_21/include/linux -g -O2 -MT BinaryConnection.o -MD -MP -MF .deps/BinaryConnection.Tpo -c -o BinaryConnection.o BinaryConnection.cc
In file included from BufferParam.hh:22:0,
from KeyValueElement.hh:24,
from InternalReader.hh:23,
from Merger.hh:22,
from OrderedIterator.hh:24,
from ReduceInputReader.hh:24,
from TaskContextImpl.hh:26,
from BinaryConnection.hh:23,
from BinaryConnection.cc:19:
Def.hh:40:31: error: ‘UINT64_MAX’ was not declared in this scope
Def.hh:41:31: error: ‘INT64_MAX’ was not declared in this scope
Def.hh:42:31: error: ‘INT64_MIN’ was not declared in this scope
Def.hh:43:31: error: ‘UINT32_MAX’ was not declared in this scope
Def.hh:44:31: error: ‘INT32_MAX’ was not declared in this scope
Def.hh:45:31: error: ‘INT32_MIN’ was not declared in this scope
Def.hh:46:31: error: ‘UINT16_MAX’ was not declared in this scope
Def.hh:47:31: error: ‘INT16_MAX’ was not declared in this scope
Def.hh:48:31: error: ‘INT16_MIN’ was not declared in this scope
Def.hh:49:31: error: ‘UINT8_MAX’ was not declared in this scope
Def.hh:50:31: error: ‘INT8_MAX’ was not declared in this scope
Def.hh:51:31: error: ‘INT8_MIN’ was not declared in this scope
There is the content of Def.hh:
18
19 #ifndef __DF_DEF_H__
20 #define __DF_DEF_H__
21 // Enable macros definition in stdint.h
22 #ifndef __STDC_LIMIT_MACROS
23 # define __STDC_LIMIT_MACROS 1
24 # undef _STDINT_H
25 #endif
26
27 #include <stdint.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <malloc.h>
31 //#include "ul_def.h"
32 // Definition of common types
33
34 typedef signed char char8;
35 typedef unsigned char u_char8;
36
37 const uint64_t MAX_U_INT64 = UINT64_MAX;
38 const int64_t MAX_INT64 = INT64_MAX;
39 const int64_t MIN_INT64 = INT64_MIN;
40 const uint32_t MAX_U_INT32 = UINT32_MAX;
41 const int32_t MAX_INT32 = INT32_MAX;
42 const int32_t MIN_INT32 = INT32_MIN;
43 const uint16_t MAX_U_INT16 = UINT16_MAX;
44 const int16_t MAX_INT16 = INT16_MAX;
45 const int16_t MIN_INT16 = INT16_MIN;
46 const uint8_t MAX_U_INT8 = UINT8_MAX;
47 const int8_t MAX_INT8 = INT8_MAX;
48 const int8_t MIN_INT8 = INT8_MIN;
49
50 #endif // #ifndef __DF_DEF_H__
51
The macros seems to make the "stdint.h" always been include,and UINT64_MAX and its'' brothers always been define;But Why the g++ complaints the errors?
解决方案
这篇关于关于c/c ++的奇怪的编译错误:"#define“永远不会工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!