integer range error in OCaml

101 views Asked by At

Recently I have to read some source code written in OCaml. And I start to read the source code after reading materials about OCaml. When I compile the source code, there's something wrong. The part which the compiler says wrong is below:


let b = [| 0x2; 0xc; 0xf0; 0xff00; 0xffff0000; 0x7fffffff00000000 |]


The error message says that's a integer range problem. I know that integer in OCaml range from -2^30 ~ 2^30 - 1 and Thus lead to that problem. But the source code is from a project that other people can use it. How can I compile it correctly? Can somebody tell me some details?

1

There are 1 answers

2
Jeffrey Scofield On BEST ANSWER

Very likely the code is intended for a 64-bit OCaml system.

As gsg suggests, you could try changing 0x2 to 0x2L and so on. If you're lucky there won't be too many things to change in the code.