I
Ioannis Vranos
Bill Seurer said:The native compilers on AIX and iSeries.
And... ?
Ioannis Vranos
Bill Seurer said:The native compilers on AIX and iSeries.
Peter van Merkerk said:The Borland and Microsoft C++ compilers have the __int64 type and if I
remember correctly GCC has the long long type.
gcc isn't a platform - it's just a compiler.
The size of long and long long varies with the target processor.
Ioannis said:And... ?
Nick said:gcc isn't a platform - it's just a compiler.
The size of long and long long varies with the target processor.
Matt said:Define 'platform'.
PlasmaDragon said:The Borland and Microsoft C++ compilers have the __int64 type and if I
remember correctly GCC has the long long type.
Bill Seurer said:The compiler determines the size of long and long long, not the target
processor. The target processor might limit the choices of what sizes
long and long long could be, though.
Nick Hounsome said:No - the compiler is configured for the processor.
If the processor does not support 64 bit then the compiler will not normally
invent code to emulate it.
Thus if you port gcc to a processor without 64 support __int64 will not
work.
True it may well allow you to use long long but this will not be 64 bits and
will almost certainly be the
same size as long so there is no point in using it.
As a general principle it is rarely correct to just use the biggest int
available in your code and hope that
it has enough bits.
Then how .NET (and i assume Win32) has an __int64 type and compilers
like the VC++ one support it? And it *is* (behaves) as an 64 bit int.
Nick said:GCC does NOT support __int64 on processors that don't support 64 bit ints.
GCC does NOT support __int64 on processors that don't support 64 bit ints.
And what? I was answering the question "Does anyone know of any
platform where long < 64 bits and long long >= 64 bits".
A compiler, libraries AND processor
No - the compiler is configured for the processor.
If the processor does not support 64 bit then the compiler will not normally
invent code to emulate it.
Thus if you port gcc to a processor without 64 support __int64 will not
work.
Jerry Coffin said:"Nick Hounsome" <[email protected]> wrote in message
[ ... ]
ints.GCC does NOT support __int64 on processors that don't support 64 bit
I'm not at all convinced that _any_ version of gcc supports __int64.
Most recent versions of gcc support long long, and it works nicely on
32-bit processors, with the compiler generating sequences of 32-bit
instructions to carry out 64-bit operations.
AFAIK, __int64 is mostly a Microsoft thing, and it's supported
primarily on 32-bit processors as well. In fact, I'm not aware of
their compiler generating 64-bit instructions for __int64 operations,
even on processors such as AMD's that support them (though I'd expect
to see it in some future version of the processor). At one time, when
they produced a processor for the Alpha, that used 64-bit instructions
for __int64, but that's been gone for quite some time.
David said:On Fri, 16 Apr 2004 07:41:16 +0100 in comp.lang.c++, "Nick Hounsome"
However, when Walter Bright writes Digital Mars C++
(http://www.digitalmars.com) for a processor with no 64bit
registers and no 64 bit arithmetic, __int64 does work and is 64 bits.
Any compiler that uses less than 64 bits for __int64 is just broken.
David said:On Fri, 16 Apr 2004 07:36:24 +0100 in comp.lang.c++, "Nick Hounsome"
You just made that up.
And of the three, it is the compiler that determines the sizes of the
integral types that it provides to you.
Ioannis Vranos said:Then how .NET (and i assume Win32) has an __int64 type and compilers like
the VC++ one support it? And it *is* (behaves) as an 64 bit int.
Nils Petter Vaskinn said:I am more interested in practical portability than in ISO standards.
Also it seems to be irrelevant whether the 64-bit type is long or long long.
Which C++ compilers do and which do not have 64-bit integer types? And
do they have something like stdint.h?
Something like this may work if you really want it portable:
#if <some magic to detect 64bit long>
typedef long my64bit_t;
#elif <some magic to detect 64 bit long long>
typedef long long my64bit_t;
#elif <some magic to detect 64 bit int>
typedef int my64bit_t;
#else
class my64bit_t {
public:
my64bit_t();
my64bit_t(long x);
my64bit_t(unsigned char* bytes);
...
my64bit_t operator +(my64bit_t a, my64bit_t b);
...
my64bit_t operator << (my64bit_t a, int n);
...
private:
unsigned char data[8]; /* assuming 8 bit bytes */
};
/* or perhaps just #include <bigintlibrary.h> and then a single
typedef */
#endif
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.