dylan-lang / melange

C-FFI interface generator for Open Dylan
http://opendylan.org/documentation/melange/
Other
7 stars 7 forks source link

<char*> & <c-string> #5

Open iglennrogers opened 12 years ago

iglennrogers commented 12 years ago

Having a naked import:declaration, gives a line in the translation as : define C-pointer-type <char*> => <C-signed-char>; with <char*> used in function declarations. However, these are unable to be directly assigned to a <string>.

Having a line equate: { "char *" => <c-string> } allows an assignment to <string>, but gives the following error.

Serious warning at sqlib-base-ffi.dylan:12:

Attempt to define variable {<C-string> in c-ffi-interface} owned by another library, definition ignored.

sqlib-base-ffi.dylan:11: ---------------------------------------------------
sqlib-base-ffi.dylan:12: define C-pointer-type <c-string> => <C-signed-char>;
sqlib-base-ffi.dylan:13: ---------------------------------------------------

It might be worthwhile having the define C-pointer-type <char*> => <C-signed-char>; line in the cffi library in addition to the <c-string> definition (assuming that's where it is) (there must be other common substitutions as well), but then not writing anything into the dylan file, so the error isn't generated, especially if it's marked as 'serious'

waywardmonkeys commented 12 years ago

What if you do:

  #include "whatever.h",
    equate: {"char *" => <c-string>},
    map: {"char *" => <byte-string>};

?

iglennrogers commented 12 years ago

You still get define C-pointer-type <c-string> => <C-signed-char>; written into the file - this is incidentally just before it's first required.