-
Notifications
You must be signed in to change notification settings - Fork 121
Description
c-fo-go has a fixed type mapping to map c types to go types. this is defined in
c-for-go/translator/type_mapping.go
Line 53 in eaf8c81
var builtinCTypeMap = CTypeMap{ |
the base for this mapping is https://en.wikipedia.org/wiki/C_data_types which is based on the c standard. the problem on these mapping are, they do not account for the data model the system uses.
For example a long int
has to be, according to the standard at least 32bit, but on today's 64bit processors it's 64bit as well. at least on x86_64-linux-gnu, a int64_t
is defined as long int
and not, as one may expect, as long long int
. therefor c-for-go translates this int64_t
to golang's int32
instead of int64
.
I suggests the translations map should also consider the data model the user expect to use. There's already an Arch settings in the yaml file which may be used. Maybe an OS setting is also needed. For a definition on data models and datatype size, the cpp reference provides a overview at https://en.cppreference.com/w/cpp/language/types
see also #120