Skip to content

Commit

Permalink
Treat long int types properly (long -> int32) to have exact bitsize.
Browse files Browse the repository at this point in the history
Note that standards say "long guarantees at least 32 bits", which means we could use
just int and uint Go types for that. But on practice that's very platform dependent and most
code is using int32_t and uint32_t and users expect to have int32 and uint32 in Go bindings.

https://en.cppreference.com/w/cpp/language/types
  • Loading branch information
xlab committed Nov 15, 2020
1 parent ea6dce5 commit ddcfe26
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions translator/type_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ var builtinCTypeMap = CTypeMap{
// unsigned short -> uint16
CTypeSpec{Base: "short", Unsigned: true}: Uint16Spec,
// long -> int
CTypeSpec{Base: "long"}: IntSpec,
CTypeSpec{Base: "long"}: Int32Spec,
// unsigned long -> uint
CTypeSpec{Base: "long", Unsigned: true}: UintSpec,
CTypeSpec{Base: "long", Unsigned: true}: Uint32Spec,
// signed long -> int
CTypeSpec{Base: "long", Signed: true}: IntSpec,
CTypeSpec{Base: "long", Signed: true}: Int32Spec,
// long long -> int64
CTypeSpec{Base: "long", Long: true}: Int64Spec,
// unsigned long long -> uint64
Expand All @@ -86,11 +86,11 @@ var builtinCTypeMap = CTypeMap{
// signed short int -> uint16
CTypeSpec{Base: "int", Short: true, Signed: true}: Int16Spec,
// long int -> int
CTypeSpec{Base: "int", Long: true}: IntSpec,
CTypeSpec{Base: "int", Long: true}: Int32Spec,
// unsigned long int -> uint
CTypeSpec{Base: "int", Long: true, Unsigned: true}: UintSpec,
CTypeSpec{Base: "int", Long: true, Unsigned: true}: Uint32Spec,
// signed long int -> uint
CTypeSpec{Base: "int", Long: true, Signed: true}: IntSpec,
CTypeSpec{Base: "int", Long: true, Signed: true}: Int32Spec,
// float -> float32
CTypeSpec{Base: "float"}: Float32Spec,
// double -> float64
Expand Down

0 comments on commit ddcfe26

Please sign in to comment.