lacc
lacc copied to clipboard
Size of standard types
I see that typetree.c hardcodes the size of standard types (char, short, int, float, etc...) to those of the typical x86_64 platforms... I feel this can be a cause for issues on some platforms if for some reason the host compiler has a different size for some of these types (which I guess can happen even if it's x86_64, because I don't think it's forbidden for a compiler to take, let's say, 4 bytes for short ints if it wishes to do so).
So, I believe lacc should have its own limits.h in the include/stdlib folder, because AFAIK the sizes of these types is compiler-specific rather than OS-specific.
Also, I suggest to list the sizes of these standard types at the toplevel readme.
By the way, if I'd like to change the sizes of the standard types (obviously for using lacc in AST mode only, because generating assembly would require writing a new backend), is typetree.c the only place where I need to set the type sizes, or should I modify other files too?
Regarding different type sizes, I think the correct way to look at this is to do a mapping closer to the front-end. If for example we want to have sizeof(long) = 4 instead of 8, then "long" should not map to T_LONG in lacc, but rather T_INT. I have thought about this, and for platform compatibility (for ex with windows) it is definitely something I want to look at at some point.