Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000558OCamlCamlIDLpublic2001-10-07 08:132002-01-16 17:16
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000558: camlidl: big int32 consts
DescriptionFull_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:

1.

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

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

2.

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:

3.

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

 
 

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000073)
administrator (administrator)
2001-10-12 16:01

> 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

(0000074)
administrator (administrator)
2002-01-16 17:16

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

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker