ocaml-ctypes icon indicating copy to clipboard operation
ocaml-ctypes copied to clipboard

define `CAML_COMPATIBILITY_H` to allow more idents

Open yilinwei opened this issue 3 years ago • 1 comments

compatibility.h defines preprocessor macros which means certain identifiers, such as alloc cannot be used. The preprocessor expands the identifier into caml_xxx in the offset_of.

This is a problem when binding with cstubs when structs have fields with the same identifiers. Currently, you can manually add this #define in the preamble manually as a workaround.

Note: compatibility.h is removed in ocaml 5, but is present until 4.14.

yilinwei avatar Jul 22 '22 16:07 yilinwei

I think the proper fix is to make sure that we're using "namespaced" identifiers in the C code (that is, starting with caml_ when they're defined in the caml headers, and define CAML_NAME_SPACE which prevents the compatibility.h header from being included. Surely we don't have to support OCaml versions that are older than the switch to prefixed identifiers?

MisterDA avatar Jan 12 '23 15:01 MisterDA