40
votes

I declare a variable for a 64 bit counter as :

long long call_count;

What is the format specifier that I should use in print statements?

I tried, %l, %ld, %ll. None seems to be correct.

I use Diab C compiler for compiling my application code to run on pSOS operating system.

7

7 Answers

65
votes

According to C99, it should be "%lld" (see, for example,here). If Diab C isn't C99, then you'd have to look at the compiler docs, which I can't seem to find online with a quick Googling.

15
votes

It's "%lli" (or equivalently "%lld")

11
votes

Microsoft and Watcom use %I64d (capital eye), others use %lld (lowercase ell ell).

5
votes

This one and even little more has been described here: cross-platform printing of 64-bit integers with printf

TL;DR: You can use PRId64 macro (from inttypes.h) to print 64 bit integers in decimal in a semi-portable way. There are also other macros (like PRIx64).

2
votes

Maybe %lld? I think this is the format for gcc, don't know anything about Diab C compiler.

1
votes

It is %lld for signed and %llu for unsigned

0
votes
long long t1;             //signed
unsigned long long t2;    //unsigned

printf("%lld",t1);
printf("%llu",t2);