This is how LWT_ELEMID defined in liblwgeom_topo.h:
typedef int64_t LWT_INT64;
typedef LWT_INT64 LWT_ELEMID;
I include this .h file and define some argument in LWT_ELEMID type.
But it always warns me like this:
/home/user/xxx.c:880:36: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘LWT_ELEMID’ {aka ‘const long int’} [-Wformat=]
or like this:
/home/user/xxx.c:3034:19: note: expected ‘LWT_ELEMID *’ {aka ‘long int *’} but argument is of type ‘lint64 *’ {aka ‘long long int *’}
my environment:
Thread model: posix
gcc version: 8.3.0 (Ubuntu 8.3.0-6ubuntu1)
Target: x86_64-linux-gnu
2
Answers
For strange reasons, gcc for Linux went with making
long
64 bits (even thoughlong long
has been available forever), thereby breaking backwards compatibility with 32 bit systems. So you have to use%ld
, or better yet, avoid this wholelong
debacle and use the portablePRIi64
conversion specifier from inttypes.h.Example:
The reason is the underlying data model of your target platform.
What you are seeing is the
LP64
data model (long
(as opposed to long long) andpointer
are 64bit), which according to Wikipedia is used bywhereas the
LLP64
data model (long long
(as opposed to ordinary long) andpointer
are 64bit) is (according to the same source) prevalent onsince
int64
are (by definition) always 64bit integers, and in theLP64
modellong int
are also 64bit integers, the two types are the same.