[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is this mingw bug?



On 2008-02-10 15:57 +0100, Misko wrote:

> I am trying to compile some program with mingw but I get some
> strange behavior. The problem is with long long int numbers
> and/or shift operator.
>
> When I compile simple program (included bellow) with linux gcc
> I get result that I expect:
>
> $ ./big_num
> sizoef(tick): 8
> Big number: 4611686018427387904
>
> If I compile it with i586-mingw32msvc-gcc this is what I get
>
> $ wine big_num.exe
> Sizoef(tick): 8
> Big number: 0
> Wine exited with a successful status
>
> Anybody know what the problem can be?
> Is it wingw, wine, or windows?

It is MinGW's printf implementation that is different.  The first
Google hit searching for "mingw long long" shows that:

http://www.mingw.org/MinGWiki/index.php/long%20long

> And how do I use long long int variables on windows platform?

Just as on GNU/Linux, only the format specifier in *printf() is
different.

> #include <stdio.h>
>
> int
> main(int argc, char **argv)
> {
>         long long int tick = 1;
>         printf("sizoef(tick): %d\n", sizeof(tick));
>         tick <<=  62;
>         printf("Big number: %lld\n", tick);
                              ^^^^
           In MinGW, you need %I64d instead.
>
>         return 0;
> }

Sven


Reply to: