Reputation:
I'm using (under windows7, VS2010) a time_t
type.
So...
If I dump my variable with a simple printf("%d", myvar)
Everything is working fine.
But now, If I use a vsnprintf()
(or any code using va_start/va_end and co...)
with time_t as argument, I get wrong values !?
myprintf(">>%d %d", var1_time, var2_time);
(var1_time and var2_time are both wrong !)
my guess: va_xx functions don't know how to handle 64bit !?
Of course I can use "%lld" but... How can I do act like printf ?
Upvotes: 0
Views: 587
Reputation: 229204
It's just luck that it worked with printf.
time_t is 64 bit (unless you enable the 32 bit version). So using "%d" is wrong. I'm guessing it appears to work as the stack in that case happens to contains zeroes where printf expects to find the upper 4 bytes of your time_t.
Print it as a 64 bit type in both cases.
If you really must treat it as a 32 bit value, you have to cast it, printf("%d", (int)myvar); . But don't do that, dealing with time is cumbersome enough that you don't need to deliberately try to mess it up.
Upvotes: 2