jserv / amacc

Small C Compiler generating ELF executable Arm architecture, supporting JIT execution
Other
1.01k stars 160 forks source link

Add support for C language unions. #89

Closed HPCguy closed 2 years ago

jserv commented 2 years ago

I wonder the case when a union consists of char and init. That is,

union foo {
   char a;
   int b;
};

Would sizeof work as expected for the permutations of primitive types?

Your implementation looks much smaller than what I guessed.

HPCguy commented 2 years ago

The sizeof will work the same as it did before for members of a struct. I think the size determination logic is pretty accurate in AMaCC.

I was wondering when you would spot the trend for lines of code changed vs functionality provided. :) I think you will find that is essentially always true. That said, it is especially easy for AMaCC because AMaCC was well designed for what it provides.

jserv commented 2 years ago

Thank @HPCguy for the work again!