Mail Archives: djgpp/1998/02/19/13:06:15
: >> Is there a way so I can specify the size of an integer in DJGPP. In MSDN
: >> help, it says that MSVC++ 5.0 has the following integer sizes:
: >> <...snip...>
: >> I am doing a program that calculates prime numbers, so the bigger the
: >> better. Is there any way I can get a 4 or 8 byte integer in DJGPP?
Hello there, and please let me knote that I'm answering a quote from a
thread where the original post seems to be missing.
My quick answer would be that for a 4-byte integer in DJGPP, just use int
-- unless you want to ensure compatibility with other compilers which may
define int as 2 bytes -- or maybe 8 bytes -- and decide to use the long
type (guaranteed to be _at least_ 4 bytes on ANSI C compilers).
While I tend to use int, people following good programming guidelines for
portability would want _not_ to assume that an int is 32 bits, especially
given the converse problems often reported by people who assume that an
int is 2 bytes -- a point convered in the DJGPP FAQ.
For an 8-byte int in DJGPP, you can use the long long type, although this
is GNU-specific and not guaranteed to be supported on all compilers, at
least under 1989 ANSI C, if I'm correct.
Maybe I'm missing something here, but in DJGPP it seems very
straightforward to me to get either a 4-byte or 8-byte integer.
Most respectfully,
Margo Schulter
mschulter AT value DOT net
- Raw text -