Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Type translation does not respect systems data model #138

@bearsh

Description

@bearsh

c-fo-go has a fixed type mapping to map c types to go types. this is defined in

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

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions