Is it time to stop using CAMLprim, CAMLexport, and CAMLextern?

I was curious why we have these macros, when both CAMLprim and CAMLexport are empty definitions and CAMLextern is simply extern. The comment above these defines in misc.h says something about Windows DLLs, but it’s unclear what that could possibly mean.

I traced the history of misc.h and finally found this commit from Alain Frisch:

It seems that these macros did have some significance before OCaml 3.11, as they would emit Microsoft-specific attribute syntax causing the definitions to be visible from a DLL. Since the linked diff, these macros are vestigial.

I understand that the OCaml runtime headers need to continue to define these macros for backwards compatibility, but I’ve also noticed that new C code continues to use these macros. The OCaml documentation for Interfacing with C includes CAMLprim in its examples.

Is it by design that C stub authors should continue to use these macros?

1 Like

I have found that they still have some good value as documentation (especially CAMLprim).