[LLVMdev] Say hi to VMKit: JVM/LLVM, CLI/LLVM
sabre at nondot.org
Thu Mar 27 21:16:53 PDT 2008
On Mar 27, 2008, at 2:18 PM, Eric Gouriou wrote:
> On Mar 26, 2008, at 12:23 PM, Török Edwin wrote:
>>> 2) ISO C++ does not support %jd. x86_64 does not know about %lld?
>> It does, but gcc gives a warning, if I use %lld I get a warning on
>> x86_64, if I %ld I get a warning on x86-32.
>> int64_t is long int on x86-64. However sizeof(long int) ==
>> long int), so I don't know why gcc insists it is wrong.
>> I only found %jd which doesn't give warnings on either:
> To print a int64_t value, use PRId64 from inttypes.h if you can.
> #include <inttypes.h>
> int64_t x = ...;
> printf("x=%"PRId64"\n", x);
> It's ugly at first, but portable (provided inttypes.h ...).
Unfortunately, inttypes.h isn't portable either :(.
printf("%lld", (long long)x);
which is guaranteed to work and is fine on any system where
sizeof(int64_t) == sizeof(long long). LLVM already makes lots of
assumptions that this is true already, so one more won't hurt.
More information about the llvm-dev