FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 02-10-2008, 01:57 PM
Misko
 
Default Is this mingw bug?

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?
And how do I use long long int variables on windows platform?

#include <stdio.h>

int
main(int argc, char **argv)
{
long long int tick = 1;
printf("sizoef(tick): %d
", sizeof(tick));
tick <<= 62;
printf("Big number: %lld
", tick);

return 0;
}

Misko


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 02-10-2008, 03:57 PM
Sven Joachim
 
Default 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
", sizeof(tick));
> tick <<= 62;
> printf("Big number: %lld
", tick);
^^^^
In MinGW, you need %I64d instead.
>
> return 0;
> }

Sven


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 02-10-2008, 04:56 PM
Misko
 
Default Is this mingw bug?

On Sun, Feb 10, 2008 at 05:57:51PM +0100, Sven Joachim wrote:
> > 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.
> > printf("Big number: %lld
", tick);
> ^^^^
> In MinGW, you need %I64d instead.

Thank you. Now it works!

So it seems to be windows bug after all

Misko


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 08:41 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org