chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Including C struct definitions


From: Nicolas Pelletier
Subject: [Chicken-users] Including C struct definitions
Date: 20 Dec 2004 11:41:10 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Hello,

I am  using Chicken 1.72 and would  like to embed C  structs in Scheme
code. Some fields in  these structures are themselves structued types,
and csc gives an error on  such structures. Here is what my code looks
like:

my_structs.scm:
#>!
#include "my_structs.h"
<#

my_structs.h:
typedef struct
{
      unsigned char a;
      unsigned char b;
} a_t;

typedef struct
{
      a_t c;
      unsigned long int d;
} b_t;

csc gives the following error:
csc my_struct.scm -output-file my_struct.c
Error: invalid type specifier: (struct (scope (unsigned char (id "a")) 
(unsigned char (id "b"))))
*** Shell command terminated with exit status 1: 
/home/nicolasp/SunOS/chicken/bin/chicken struct.scm -output-file struct.c 
-quiet -output-file struct.c

I tried the following trick without success:
struct a_s
{
      unsigned char a;
      unsigned char b;
};
typedef struct a_s a_t;

struct b_s
{
      struct a_s c;
      unsigned long int d;
};
typedef struct b_s b_t;

This one chokes on the definition of the field called d.

Is there a way to make this kind of structured types work ?

Thanks in advanve !

-- 
Nicolas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]