mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-18 19:44:00 +00:00
cgo: implement C unions
Unions are somewhat hard to implement in Go because they are not a native type. But it is actually possible with some compiler magic. This commit inserts a special "C union" field at the start of a struct to indicate that it is a union. As such a field cannot be written directly in Go, this is a useful to distinguish structs and unions.
This commit is contained in:
committed by
Ron Evans
parent
536086988c
commit
d2b3a5486c
Vendored
+10
@@ -14,3 +14,13 @@ double: +3.200000e+000
|
||||
complex float: (+4.100000e+000+3.300000e+000i)
|
||||
complex double: (+4.200000e+000+3.400000e+000i)
|
||||
complex long double: (+4.300000e+000+3.500000e+000i)
|
||||
struct: true 256 -123456 +3.140000e+000
|
||||
array: 5 6 7
|
||||
union: true
|
||||
union s: 22
|
||||
union f: +3.140000e+000
|
||||
union global data: 5 8 1
|
||||
union local data: 5 8 1
|
||||
union s method: -33 false
|
||||
union f: +6.280000e+000
|
||||
union field: +6.280000e+000
|
||||
|
||||
Reference in New Issue
Block a user