How should i use 64-bit data in GCC under Linux?

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
miracle
New poster
Posts: 10
Joined: Sat Apr 16, 2005 9:40 am

How should i use 64-bit data in GCC under Linux?

Post by miracle » Fri Apr 29, 2005 3:17 pm

#include <iostream.h>

int main()
{
cout<<sizeof(__int64)<<endl;
}

comiple using G++:
error: `__int64' undeclared (first use this function)

But I can use the same code in Vim for Windows XP with no error.
Why? Who can help me?

User avatar
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba » Fri Apr 29, 2005 3:51 pm

But I can use the same code in Vim for Windows XP with no error.
So? Vim is just an editor. You could use the same code in MS Word for Windows XP with no error as well.

By the way, did you try searching the board?

miracle
New poster
Posts: 10
Joined: Sat Apr 16, 2005 9:40 am

Post by miracle » Sat Apr 30, 2005 10:30 am

oh , sorry, i did not express it clearly. i mean that i comiple the same code using G++ with no
error under Win XP

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Sat Apr 30, 2005 10:43 am

In Cygwin and Mingw, "__int64" is defined as a macro, for compatibility with Microsoft's code.

64-bit integer types in GCC are "long long" and "unsigned long long".

miracle
New poster
Posts: 10
Joined: Sat Apr 16, 2005 9:40 am

Post by miracle » Sat Apr 30, 2005 11:13 am

Thanks to mf, i've got it

User avatar
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba » Sat Apr 30, 2005 12:48 pm

mf wrote:In Cygwin and Mingw, "__int64" is defined as a macro, for compatibility with Microsoft's code.
Well, the part about Mingw it true, but about Cygwin - not. miracle's code fails there as expected.

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Sat Apr 30, 2005 4:45 pm

Ah yes, you're right.
I didn't try to compile the code, just looked at the headers. In cygwin, __int64 gets defined when you include some windows-specific file, like windows.h.

Post Reply

Return to “C++”