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

Make P6 "int" always match C "int" (or provide an alternative) #6673

Open
p6rt opened this issue Feb 13, 2018 · 1 comment
Open

Make P6 "int" always match C "int" (or provide an alternative) #6673

p6rt opened this issue Feb 13, 2018 · 1 comment

Comments

@p6rt
Copy link

p6rt commented Feb 13, 2018

Migrated from rt.perl.org#132864 (status was 'new')

Searchable as RT132864$

@p6rt
Copy link
Author

p6rt commented Feb 13, 2018

From @jimav

Hello,

Please see Raku/doc#1771 for motivation.

In brief​: The P6 "native" type int is currently not guaranteed to be the
same as an "int" in C, which prevents portably using "int" with
NativeCall to interface to C code which has "int" arguments.

My suggestion​:

Officially guarantee that P6 "int" will always match a C "int" on the
current platform.  Document that portable code should assume a range of
-32768..32767 (16 bits), which is the minimum required by C99.
This change will allow "int" to be used portably with NativeCall and
DWIM on all platforms.

Alternatively​:

Define another "native" type which _is_ guaranteed to be the same as a C
"int", and document it's use with NativeCall.
If this solution is taken, then make the compiler emit an error if "int"
is used in a CStruct or similar constructs, to prevent people from
thinking they are writing portable code.


Relatedly, there should be a native "unsigned" which is guaranteed to
match a C "unsigned", for use with NativeCall.

-Jim

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

No branches or pull requests

1 participant