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 »

#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?
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba »

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 »

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 »

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 »

Thanks to mf, i've got it
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba »

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 »

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++”