Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is_young references a hidden type #8892

Open
dra27 opened this issue Aug 24, 2019 · 1 comment · May be fixed by #8895

Comments

@dra27
Copy link
Contributor

commented Aug 24, 2019

The definition of Is_young uses the type addr:

#define Is_young(val) \
(CAMLassert (Is_block (val)), \
(addr)(val) < (addr)caml_young_end && (addr)(val) > (addr)caml_young_start)

which is defined in misc.h, but it is guarded by CAML_INTERNALS:

#ifdef CAML_INTERNALS
typedef char * addr;
#endif /* CAML_INTERNALS */

where the definition of Is_young is not. So at the moment Is_young produces an error if CAML_INTERNALS isn't defined in user code. There are three trivial fixes, the non-trivial part is which it should be:

  1. Remove the guard around the typedef in misc.h
  2. Add a guard around the definitions in address_class.h
  3. Add the typedef in address_class.h guarded with #ifndef CAML_INTERNALS (yuck...)
@xavierleroy

This comment has been minimized.

Copy link
Contributor

commented Aug 24, 2019

Let me add a fourth fix: use char * instead of addr in Is_young (like Is_in_code_area does, a few lines below Is_young).

Going further, I would suggest to remove the type name addr. Many variables and macro parameters are named addr in the runtime code base, so it's not a great idea to use addr as a type name. Plus, there are only 8 uses or so of the addr type name in our code base.

If we have cold feet and suspect 3rd-party sources to #define CAML_INTERNALS, we could keep the typedef char * addr; protected by #ifdef CAML_INTERNALS, perhaps with a deprecation warning attached, but still stop using it in Is_young and the rest of the code base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.