Guile的make-c-struct(系统外来的)

时间:2017-06-05 14:20:52

标签: scheme guile

Guile接受以下代码:

(use-modules (system foreign))
(define ptr (make-c-struct (list int int) '(300 43)))

但是,当第二行替换为:

时会抛出错误
(define ptr (make-c-struct '(int int) '(300 43)))

是否有人能够推断出问题所在?

$ guile --version
guile (GNU Guile) 2.0.13

$ uname -a 
Linux <host> 4.8.0-1-amd64 #1 SMP Debian 4.8.5-1 (2016-10-28) x86_64 GNU/Linux

Backtrace:
In ice-9/boot-9.scm:
 160: 8 [catch #t #<catch-closure 55b8628b8600> ...]
In unknown file:
   ?: 7 [apply-smob/1 #<catch-closure 55b8628b8600>]
In ice-9/boot-9.scm:
  66: 6 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 432: 5 [eval # #]
In ice-9/boot-9.scm:
2404: 4 [save-module-excursion #<procedure 55b8628d89c0 at ice-9/boot-9.scm:4051:3 ()>]
4058: 3 [#<procedure 55b8628d89c0 at ice-9/boot-9.scm:4051:3 ()>]
In /home/<user>/path/tofile.scm:
   7: 2 [#<procedure 55b862cf46c0 ()>]
In system/foreign.scm:
 158: 1 [make-c-struct (int int) (300 43)]
In unknown file:
   ?: 0 [sizeof (int int)]

ERROR: In procedure sizeof:
ERROR: In procedure alignof: Wrong type argument in position 1: int

1 个答案:

答案 0 :(得分:2)

此:

(list int int)

创建一个列表,其中包含先前定义的int值作为元素,而这个:

'(int int)

创建一个包含两个符号作为元素的列表,它们不等效,请记住单引号是(quote (int int))的简写,而不是(list int int)