This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Warning using sprintf("%llu", uint64_t) on AMD64


routines.cpp: In function 'const std::string uint64toString(const
uint64_t&)':
routines.cpp:87: warning: format '%llu' expects type 'long long unsigned
int', but argument 4 has type 'long unsigned int'
routines.cpp:87: warning: format '%llu' expects type 'long long unsigned
int', but argument 4 has type 'long unsigned int'
routines.cpp: In function 'const std::string int64toString(const int64_t&)':
routines.cpp:93: warning: format '%lld' expects type 'long long int',
but argument 4 has type 'long int'
routines.cpp:93: warning: format '%lld' expects type 'long long int',
but argument 4 has type 'long int'


    Now, in fact I am not using 'long long unsigned int' nor 'long
unsigned int' but rather uint64_t and int64_t

From stdint.h

# if __WORDSIZE == 64
typedef long int                int64_t;
# else
__extension__
typedef long long int           int64_t;
# endif

    Further I've verified that long int is 64bits on AMD64, and long
long is 64bits on AMD64.

    These warnings feel bogus, the only thing I can think of is that on
some platforms, 'long long' might be 128-bit. But then then suggests the
question of how do I do an sprintf portably with 64-bit ints?
    Is there a [good] reason for this warning, and what should I do
about it (even if the reason is bad, I need to silence the warning)

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]