Originally Posted by
laserlight
Now, let us restate quzah's statements:
Originally Posted by
quzah
You are still defining a new type. That has to be kept some place. As such, that new type's definition should in my thinking be taking up some space. Now I suppose it's possible, that if you don't actually ever declare an instance of that type, that the compile optimizes it out. But it's my thinking that since you're declaring a new type, that new type must be kept track of some place.
My initial impression of that was that it made no sense. What is there to keep track of, exactly, except the names and the corresponding values? It's an int(eger type), not a new type (except in the "ooh it has a name" sense) after all. So, I have two versions of temp.c and the corresponding temp.s, created with gcc on MinGW with no optimizations.
The first temp.c:
Code:
enum teAccessCtrl {
IDLE_ST = 0x01,
RX_ST,
TX_ST,
NO_ST,
};
int main() {
enum teAccessCtrl foo;
foo = RX_ST;
return 0;
}
and the corresponding temp.s:
Code:
.file "temp.c"
.def ___main; .scl 2; .type 32; .endef
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
movl $0, %eax
addl $15, %eax
addl $15, %eax
shrl $4, %eax
sall $4, %eax
movl %eax, -8(%ebp)
movl -8(%ebp), %eax
call __alloca
call ___main
movl $2, -4(%ebp)
movl $0, %eax
leave
ret
The second temp.c:
Code:
#define IDLE_ST 0X01
#define RX_ST 0x02
#define TX_ST 0x03
#define NO_ST 0x04
int main() {
int foo;
foo = RX_ST;
return 0;
}
and the associated temp.s:
Code:
.file "temp.c"
.def ___main; .scl 2; .type 32; .endef
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
movl $0, %eax
addl $15, %eax
addl $15, %eax
shrl $4, %eax
sall $4, %eax
movl %eax, -8(%ebp)
movl -8(%ebp), %eax
call __alloca
call ___main
movl $2, -4(%ebp)
movl $0, %eax
leave
ret
Yes, yes, toy example, etc. I have no doubt that declaring a nice big struct might put some information in the file (haven't done the test, not that motivated). But I would be surprised if an enum put anything like type information in the compiled result.