Steve Searle <st...@...> wrote: > > I'm trying to use stdint.h after seeing it mentioned here > the other day. Using g++ under fedora.
GNU's support of C99 is incomplete... http://gcc.gnu.org/c99status.html For the most part though, it is fairly straight forward to create and substitute your own. There are a few custom headers on the net. > I have the following line: > > uint8_t Team::min_earliest_round = UINT8_MAX; > > uint8_t is fine but UINT8_MAX is "not declared in this scope". > If I replace UINT8_MAX with 255 the program compiles cleanly. > > The stdint.h header file contains: > > 145 /* The ISO C99 standard specifies that in C++ implementations these > 146 macros should only be defined if explicitly requested. */ > 147 #if !defined __cplusplus || defined __STDC_LIMIT_MACROS > 148 > 149 # if __WORDSIZE == 64 > 150 # define __INT64_C(c) c ## L > 151 # define __UINT64_C(c) c ## UL > 152 # else > 153 # define __INT64_C(c) c ## LL > 154 # define __UINT64_C(c) c ## ULL > 155 # endif > 156 > 157 /* Limits of integral types. */ > 158 > 159 /* Minimum of signed integral types. */ > 160 # define INT8_MIN (-128) > 161 # define INT16_MIN (-32767-1) > 162 # define INT32_MIN (-2147483647-1) > 163 # define INT64_MIN (-__INT64_C(9223372036854775807)-1) > 164 /* Maximum of signed integral types. */ > 165 # define INT8_MAX (127) > 166 # define INT16_MAX (32767) > > > I presume I need to define something to cause line 165 to > be active, but I'm not sure what, where or how. By the looks of it, __STDC_LIMIT_MACROS. Try adding the switch -D__STDC_LIMIT_MACROS to your compiler flags. I've never actually used <stdint.h> in anything non-trivial. I prefer to make code unreliant on fixed width types being available. Integral and arithmetic promotion is an important element of even simple C expressions. The intN_t types make such promotions less clear. As Thomas' blog points out, machine word lengths keep getting wider and wider over time. I may regret saying it, but I think there's a limit to the gain from increasingly wider types. That said, I do believe that CHAR_BIT == 32 or 64 will be the norm one day, even for hosted implementations. -- Peter
