Mail Archives: djgpp/2000/06/05/07:10:47
Radical NetSurfer wrote:
> void main(void) {
Make that:
int main(void) {
> // printf("The size_of a Enum is %ld\n", sizeof(enum));
[snip]
> QUESTION:
> Why is not proper to use 'enum' in Size_of ??
> Normally, this is defined as 2-Bytes (=to short or int),
> but in DJGPP, its a SYNTAX error....
You can't do sizeof(enum) for the same reason that you can't do
sizeof(struct) or sizeof(union). It just doesn't make sense.
Try using sizeof on a particular enum and it will work. In DJGPP,
the size will be 1, 2 or 4, depending on how many values the enum
has and whether or not you compiled with -fshort-enums.
By the way, your code also assumes that it's OK to print a size_t as
if it were a long. This will work in DJGPP, but you should cast it
to be safe (and use unsigned long rather than long).
S.
- Raw text -