Registering types with long members generates warnings
Since #726 if we wrap a system long type in our Long type, this can lead to warnings from the C compiler. See for instance the tm datatype, provided by time.h:
; typedef struct tm TM;
(register-type TM [
tm_sec Int,
tm_min Int,
tm_hour Int,
tm_mday Int,
tm_mon Int,
tm_year Int,
tm_wday Int,
tm_yday Int,
tm_isdst Int,
tm_zone String,
tm_gmtoff Long,
])
Notice tm_gmtoff. It’s a long, not a long long/Long. On my machine (OS X 64 bit), this generates the warning:
/Users/veitheller/.carp/out/main.c:12287:36: warning: incompatible pointer types returning 'long *'
from a function with result type 'Long *' (aka 'long long *') [-Wincompatible-pointer-types]
Long* TM_tm_gmtoff(TM* p) { return (&(p->tm_gmtoff)); }
^~~~~~~~~~~~~~~~~
1 warning generated.
That makes sense, but is mildly annoying.
How do we best resolve this?
Cheers
I think we have a general issue with our type mappings -- they're not quite "configurable" enough for all possible combinations of targets and compilers. https://github.com/carp-lang/Carp/issues/872 is a great idea and sort of relates to this too.
A lot of other languages solve this with "c" types. e.g. the language has int and it also has cint which is guaranteed to be the literal int in C. I wonder if we should do something similar. It feels a bit ugly to me, but at the same time it seems like the most bulletproof way to handle types over the interop boundary.