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

camlidl: big int32 consts #2983

Closed
vicuna opened this issue Oct 7, 2001 · 2 comments
Closed

camlidl: big int32 consts #2983

vicuna opened this issue Oct 7, 2001 · 2 comments

Comments

@vicuna
Copy link

vicuna commented Oct 7, 2001

Original bug ID: 558
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues

Bug description

Full_Name: Dmitry Bely
Version: 3.02, camlidl current CVS
OS: WinNT 4.0
Submission from: d034.p8.col.ru (212.248.4.34)

I need an equivalent for the following C definitions:

#define MASK 0x7FFFFFFF /* my platform is IA32 */
#define SIGN 0x80000000

Unfortunately it seems that CamlIDL does not allow that. What did I try:

const [int32] int SIGN = 0x80000000; /* column 6: syntax error */
const [int32] int MASK = 0x7FFFFFFF;

CamlIDL does not allow attributes for consts. OK, second attempt:

typedef [int32] int i32;
const i32 SIGN = 0x80000000;
const i32 MASK = 0x7FFFFFFF;

compiles silenly, but produces

(* File generated from mask.idl *)
type i32 = int32
let sIGN = Int32.of_int 0
let mASK = Int32.of_int -1

That's not what I need! 3rd attempt:

typedef [int32] int i32;
const i32 _2x30 = 0x40000000;
const i32 SIGN = _2x30 * 2 ;
const i32 MASK = _2x30 * 2 - 1;

gives exactly the same result

(* File generated from mask.idl *)
type i32 = int32
let _2x30 = Int32.of_int -1073741824
let sIGN = Int32.of_int 0
let mASK = Int32.of_int -1

What would you recommend to work around this? Maybe it is worth introducing long
int32/int64 integer literals (like 0x7FFFFFFFL) to OCaml/CamlIDL, that have an
appropriate type?

Hope to hear from you soon,
Dmitry

@vicuna
Copy link
Author

vicuna commented Oct 12, 2001

Comment author: administrator

What would you recommend to work around this? Maybe it is worth
introducing long int32/int64 integer literals (like 0x7FFFFFFFL) to
OCaml/CamlIDL, that have an appropriate type?

I agree the current CamlIDL essentially doesn't support int32 or int64
constants, but it should. I'll look into adding decent support, both
syntactically ([int32] and [int64] annotations on const) and semantically
(compute integer expressions with the appropriate precision, as in C).

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Jan 16, 2002

Comment author: administrator

Revised const handling and integer arithmetic on constants. XL, 2002-01-16

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