steve said:
in fact, what i want to know is the size of the native long type of the
c compiler, at compile time. [...]
You can discover the bounds of the `long' type easily
enough by using the <limits.h> macros:
#include <limits.h>
#if LONG_MAX == 0x7fffffff
/* 32-bit long, the minimum size */
#elif (LONG_MAX >> 32) >= 0x7fffffff
/* 64 or more bits. Note that the `>>32' is
* not attempted until we've already established
* that `long' has >32 bits.
*/
#else
/* somewhere in 32 < bits < 64 */
#endif
You could, of course, use additional range tests to refine
the result further.
However, none of this will tell you whether the long
type is "native" in any useful sense. You cannot tell by
examining the range or size of `long' whether it is directly
supported by the hardware or emulated in software -- observe
that even an 8-bit CPU must support a `long' of at least 32
bits. Some machines even use a combination of hardware and
emulation: A system might add, subtract, and multiply `long'
values in hardware but use software for division.
At run time, you might use clock() to time a large number
of `int' and `long' calculations and try to guess from the
difference in CPU time whether there's software emulation
going on -- but that's going to be an iffy business at best
(note that the 8-bit CPU must use emulation even for `int').
You'd get a far better answer by reading the implementation's
documentation.