I have the following in a test header:
struct FunkyFrizzle
{
int integer;
float submarine;
char string[64];
};
typedef struct FunkyFrizzle FunkyFrizzle;
double int_exp(double base, int pow);
double square(double v);
The code generated by chicken-bind appears to treat "string" as a plain pointer rather than an actual array, however:
;;; GENERATED BY CHICKEN-BIND FROM test.h
(begin
(define FunkyFrizzle-integer
(foreign-lambda*
integer
(((c-pointer (struct "FunkyFrizzle")) s))
"return(s->integer);"))
(define FunkyFrizzle-submarine
(foreign-lambda*
float
(((c-pointer (struct "FunkyFrizzle")) s))
"return(s->submarine);"))
(define FunkyFrizzle-string
(foreign-lambda*
c-string
(((c-pointer (struct "FunkyFrizzle")) s))
"return(s->string);"))
(define make-FunkyFrizzle
(foreign-lambda*
(c-pointer (struct "FunkyFrizzle"))
((integer integer) (float submarine) (c-string string))
"struct FunkyFrizzle *tmp_ = (struct FunkyFrizzle *)C_malloc(sizeof(struct FunkyFrizzle));\ntmp_->integer = integer;\ntmp_->submarine = submarine;\ntmp_->string = string;\nreturn(tmp_);;\n"))
(begin
(define int_exp
(foreign-lambda*
double
((double a0) (integer a1))
"return(int_exp(a0 , a1));")))
(begin
(define square
(foreign-lambda* double ((double a0)) "return(square(a0));"))))
;;; END OF FILE
As you can see, in make-FunkyFrizzle it attempts to assign into the array (tmp_->string = string). This of course causes the C compiler to shout profanities at me.
Is there a "proper" fix for this? I assumed that this would have been caught already if it's a bug, but Google failed me there (I'm new to both scheme and chicken.) I know I could just change the code by hand, but that feels all icky and kludgy.