unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* how to access c-array member in c-structure?
@ 2016-03-30  0:13 Park SungMin
  2016-03-30  8:03 ` Taylan Ulrich Bayırlı/Kammer
  0 siblings, 1 reply; 7+ messages in thread
From: Park SungMin @ 2016-03-30  0:13 UTC (permalink / raw)
  To: guile-user


I read https://www.gnu.org/software/guile/manual/html_node/Foreign-Structs.html ..

follow c struct

struct foo {
    int a;
    int b[4];
}
then 
(let ((foo-type (list int (make-list 4 int))))
   (parse-c-struct (make-c-struct foo-type (list 1 (list 1 2 3 4))) foo-type))
is run well.

but,
typedef struct {
  int a;
  int b;
  int c[20000];
} Foo;

Foo make_foo(int a, int b) {
  Foo foo = {.a = a, .b = b};
  return foo;
}

(let ((c-type (list int int (make-list 20000 int))))
    (parse-c-struct
     ((pointer->procedure
       c-type
       (dynamic-func "make_foo" libfoo)
       (list int int))
      4 11)
     c-type))

also run well…but seems less effective.(if more bigger size…2000000??) 
 is it possible pass or return as bytevector or pointer to c-array?
(let ((c-type (list int int ‘*)) ….)  is different type….(when i try it, guile shutdown)






^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-03-31  3:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-30  0:13 how to access c-array member in c-structure? Park SungMin
2016-03-30  8:03 ` Taylan Ulrich Bayırlı/Kammer
2016-03-30  8:07   ` tomas
2016-03-30  9:03     ` Taylan Ulrich Bayırlı/Kammer
2016-03-30 16:01       ` Park SungMin
2016-03-30 19:54         ` Taylan Ulrich Bayırlı/Kammer
2016-03-31  3:02           ` Park SungMin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).