我试图获取指向结构中的double值的指针,我可以将其传递给例程,但是在获取除0
之外的任何值时都会遇到问题。以下适用于其他结构!我使用过的值(例如只包含二进制文件的值!),但在这种情况下不是:
Rebol []
speed1: make struct! [
d [double]
] [0.0]
speed1*-struct: make struct! [i [int]] third speed1
speed1*: speed1*-struct/i
以下是评估:
>> speed1: make struct! [
[ d [double]
[ ] [0.0]
>> speed1*-struct: make struct! [i [int]] third speed1
>> speed1*: speed1*-struct/i
== 0
这是二进制的工作等价物!结构:
>> binary: make struct! [bytes [binary!]] reduce [head insert/dup copy #{} 0 8]
>> binary*-struct: make struct! [i [int]] third binary
>> binary*: binary*-struct/i
== 39654648
我可以看到third
函数的区别:
>> third speed1
== #{0000000000000840}
>> third binary
== #{F8145D02}
但是,我不确定长度的差异在这种情况下意味着什么。我究竟做错了什么?是否有不同的方法将指针传递给十进制值?
答案 0 :(得分:0)
这是一种获取指向double值的指针的方法:
speed1-struct: make struct! [s [struct! [d [double]]]] [0.0]
speed1*-struct: make struct! [i [int]] third speed1-struct
speed1*: speed1*-struct/i
显示它的评估返回一个指针(显示为int
):
>> speed1-struct: make struct! [s [struct! [d [double]]]] [0.0]
>> speed1*-struct: make struct! [i [int]] third speed1-struct
>> speed1*: speed1*-struct/i
== 37329176