mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 03:27:48 +00:00
cgo: add support for C.float and C.double
They are not necessary in TinyGo because they always map to float32 and float64, but it's a good idea to add them regardless for compatibility with existing software. (Now I think about it, perhaps it would have been better to require explicit casts here just in case we want to support some really weird C system, but then again we even force 64-bit double on AVR even though avr-gcc defaults to 32-bit double).
This commit is contained in:
committed by
Ron Evans
parent
e7d02cd51b
commit
636a151ffe
Vendored
+4
-2
@@ -74,8 +74,10 @@ func main() {
|
||||
println("union:", C.int(unsafe.Sizeof(C.globalUnion)) == C.globalUnionSize)
|
||||
C.unionSetShort(22)
|
||||
println("union s:", *C.globalUnion.unionfield_s())
|
||||
C.unionSetFloat(3.14)
|
||||
println("union f:", *C.globalUnion.unionfield_f())
|
||||
C.unionSetFloat(C.float(6.28))
|
||||
println("union f (C.float):", *C.globalUnion.unionfield_f())
|
||||
C.unionSetFloat(float32(3.14))
|
||||
println("union f (float32):", *C.globalUnion.unionfield_f())
|
||||
C.unionSetData(5, 8, 1)
|
||||
data := C.globalUnion.unionfield_data()
|
||||
println("union global data:", data[0], data[1], data[2])
|
||||
|
||||
Vendored
+2
-1
@@ -32,7 +32,8 @@ struct: true 256 -123456 +3.140000e+000
|
||||
array: 5 6 7
|
||||
union: true
|
||||
union s: 22
|
||||
union f: +3.140000e+000
|
||||
union f (C.float): +6.280000e+000
|
||||
union f (float32): +3.140000e+000
|
||||
union global data: 5 8 1
|
||||
union local data: 5 8 1
|
||||
union s: true
|
||||
|
||||
Reference in New Issue
Block a user