Helmut Brandl <helmut.brandl@...> wrote on 26.02.2009 01:16:16:
> I use the type "unsigned long long" and "long long" to get 64 bit
> integers on gcc.
> For reading and writing I use the formatting e.g.
> unsigned long long u64;
> u64 = ...;
> printf("a 64 bit integer %llu\n", u64);
> This has worked up to now on all systems using gcc except on mingw and
> on cygwin compiling with the option -mno-cygwin (which the cygwin people
> told me that this implies the use of the mingw on cygwin).
> I get the following problems:
> - If I print a 64 bit integer alone, the output is ok, if I print 64 bit
> and 32 bit integers with the same print statement, the output is not the
> content of the integers.
> - If I scan a 64 bit integer and the corresponding and the variable into
> which I read is not initialized, the input is not correct.
> Is this problem known?
> Unfortunately the problem is within a big program. But if needed, I
> could try to isolate it in a small program. But I don't know, if the
> problem is deterministic, so I cannot promise that.
> Kind regards
your problem is related to the msvcrt runtime you are using. The '%ll'
isn't support natively my MS runtime. You should use for printing on mingw
the __mingw_printf function, which is capable to handle %ll proper. Sadly
there is at the moment no __mingw_scanf functionality available AFAIK.
The other thing you can do to solve this is using inttypes.h and use the
ISO define macros for your printf/scanf formatter. The ms runtime uses
%I64/%I as replacement for POSIX %ll/%z.
| (\_/) This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.