0

Guile accepts the following code:

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

However, it throws an error when the second line is replaced by:

(define ptr (make-c-struct '(int int) '(300 43)))

Is someone be able to infer what the issue could be?

$ 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
Sven Williamson
  • 1,094
  • 1
  • 10
  • 19

1 Answers1

2

This:

(list int int)

Creates a list with the previously defined int value as elements, whereas this:

'(int int)

Creates a list with two symbols as elements, they're not equivalent, remember that a single quote is a shorthand for (quote (int int)), not for (list int int).

Óscar López
  • 232,561
  • 37
  • 312
  • 386