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 nativeint intended to have the same width as a pointer or a long? #6515

Closed
vicuna opened this issue Aug 14, 2014 · 1 comment
Closed

Is nativeint intended to have the same width as a pointer or a long? #6515

vicuna opened this issue Aug 14, 2014 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Aug 14, 2014

Original bug ID: 6515
Reporter: @yallop
Status: closed (set by @damiendoligez on 2014-08-18T13:09:19Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 4.02.0+dev
Category: documentation
Monitored by: @gasche

Bug description

The documentation says that nativeint has the same width as a long:

This module provides operations on the type nativeint of signed 32-bit integers (on 32-bit platforms) or signed 64-bit integers (on 64-bit platforms). This integer type has exactly the same width as that of a long integer type in the C compiler.
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Nativeint.html

but from my reading of the source it's actually given the same width as a pointer:

#elif SIZEOF_PTR == SIZEOF_INT
/* Hypothetical IP32L64 model */
typedef int intnat;

https://github.com/ocaml/ocaml/blob/fcc2da384/byterun/config.h#L69-L72

I have a need in ctypes for an OCaml integer type that has the same width as a pointer, and it'd be useful if nativeint were guaranteed to be a suitable choice.

@vicuna
Copy link
Author

vicuna commented Aug 18, 2014

Comment author: @damiendoligez

This is a good remark, and yes nativeint is guaranteed to have the same size as a pointer.

I have changed the documentation accordingly (commit 15014 in 4.02).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant