Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
XML
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?
Posted
Updated 17-Oct-11 23:22pm
v2
Comments
Richard MacCutchan 18-Oct-11 6:08am    
Are you sure that __DF_DEF_H__ has not been defined somewhere before Def.hh was included?
linyihang 18-Oct-11 21:52pm    
Yes,there is likely to have defined somewhere before it.And did it affects something?
I have take a try as follows,but without any effect:
Modified the macros:
#ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS 1
# undef _STDINT_H
#endif
to
#ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS 1
#endif
# undef _STDINT_H

markkuk 18-Oct-11 7:42am    
It compiles without errors on my Linux system (Fedora 14, G++ 4.5.1), which distribution and compiler version are you using?
linyihang 18-Oct-11 21:11pm    
My Linux system is ubuntu11.04 ,and compiler is "g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2" and "gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2".
I have also tried the Def.hh single,and without any errors.But when with other files in the HCE(Hadoop C++ Extension)1.0 ,the compiler complaints the errors.
The even strange is,When my OS is ubuntu 10.10 a weeks ago,which have just been upgraded to ubuntu11.04 several days,I have compiled the code without any errors.

1 solution

According to this thread: http://stackoverflow.com/questions/986426/what-do-stdc-limit-macros-and-stdc-constant-macros-mean[^] you might need to #define __STDC_CONSTANT_MACROS as well. And even then there's no guarantee your stdlib actually knows and uses these symbols.
 
Share this answer
 
Comments
linyihang 18-Oct-11 21:38pm    
When I add the define of __STDC_CONSTANT_MACROS,it seems still doesn't work.And I am confused about the relationship between stdint.h and stdlib.h on the issue?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900