I know that UINT32_MAX exists, but I haven’t been able to use it. I tried printf("%d\n", UINT32_MAX); and it printed out -1. Using %ld instead of %d presented me with the error that UINT32_MAX is of the type unsigned int and needs %d to print it out.
Please help, what I ideally want is a macro/enum that holds the maximum value of word_t which is a type defined by me which currently is uint32_t.
I hope that I made clear what I want, if not please feel free to ask.
EDIT
I forgot to say what I’m actually trying to do. All of this will be used to set an array of integers all to their maximum value, because that array of integers actually is a bitmap that will set all bits to 1.
The portable way to print a
uintN_tobject is to cast it to auintmax_tand use thejlength modifier with theuconversion specifier:The
jmeans that the argument is either anintmax_tor auintmax_t; theumeans it is unsigned, so it is auintmax_t.Or, you can use the format strings defined in
<inttypes.h>(n this case, you’d usePRIu32):You can’t just use
%ubecause it isn’t guaranteed thatintis represented by at least 32 bits (it only needs to be represented by at least 16 bits).