Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
camlp4 3.10 and ints
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-06-13 (11:40)
From: Richard Jones <rich@a...>
Subject: camlp4 3.10 and ints
I'm getting some odd errors with camlp4 (3.10) and integers.

Firstly, INT returns a string, rather than an int, and similarly
$int:...$ expects a string instead of an int.  I can live with this,
but it seems a bit strange, and unless I'm mistaken is different from
what camlp4 <= 3.09 did.

Secondly, I get the error 'Failure: "Integer literal exceeds the range
of representable integers of type int"' if I try to pass a string
containing any int32 or int64 literal, eg. $int:"0x3ffL"$, even ones
which obviously do not exceed the range of representable integers.

To demonstrate this second one, save the following to files:

-------------------------------------------------- ---
open Camlp4.PreCast
open Syntax

let expand_test _loc () =
  <:str_item< value test = $int:"0x3ffL"$ >>

  GLOBAL: str_item;

  str_item: LEVEL "top" [
  [ "TEST" -> expand_test _loc () ]

-------------------------------------------------- ---

And then compile with:

  $ ocamlc -pp "camlp4o pa_extend.cmo q_MLast.cmo" -I +camlp4 -c 
  $ ocamlc -pp "camlp4o ./pa_test.cmo"
  File "", line 1, characters 0-4:
  Failure: "Integer literal exceeds the range of representable integers of type int"
  Preprocessor error

Are these bugs or am I missing something?


Richard Jones
Red Hat