From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA09701; Thu, 5 Sep 2002 14:23:20 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA09295 for ; Thu, 5 Sep 2002 14:23:19 +0200 (MET DST) Received: from hutcs.cs.hut.fi (hutcs.cs.hut.fi [130.233.192.7]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g85CNI920250; Thu, 5 Sep 2002 14:23:18 +0200 (MET DST) Received: from cessu by hutcs.cs.hut.fi with local (Exim 4.04) id 17mvfJ-00074V-00; Thu, 05 Sep 2002 15:23:17 +0300 From: Kenneth Oksanen To: xavier.leroy@inria.fr CC: caml-list@inria.fr In-reply-to: <20020905135720.D5343@pauillac.inria.fr> (message from Xavier Leroy on Thu, 5 Sep 2002 13:57:20 +0200) Subject: Re: [Caml-list] autoconf and caml References: <20020905135720.D5343@pauillac.inria.fr> Message-Id: Date: Thu, 05 Sep 2002 15:23:17 +0300 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >> I'm writing a piece of software using O'Caml and GNU autoconf (among >> others). In C the results of running `./configure' are conveniently >> accessed with `#include "config.h"'. My current solution is to >> preprocess also the O'Caml code, but this requires some clumsy hacks >> in Makefiles etc. Is there a better way? If not, then I'ld suggest >> some flag in O'Caml which would run the source files through cpp. > >The -pp flag to ocamlc and ocamlopt lets you do this easily: > ocamlc -pp /lib/cpp ... True, and this had already been kindly pointed out by some other camlers. A few remarks though: This flag is not documented on the corresponding man-pages. The flag does not exist in ocamlyacc and ocamllex. ocamllex produces code that is not cpp-safe. It contains definitions of the form Lexing.lex_base = "\000\000\255\255\254\255\002\000\248\255\001\000\247\255\246\255\ \250\255\252\255\245\255\251\255\249\255\077\000\244\255\003\000\ etc. At least when passed through GNU CPP version 2.96 20000731 (Red Hat Linux 7.3 2.96-110) these become converted to Lexing.lex_base = "\000\000\255\255\254\255\002\000\248\255\001\000\247\255\246\255 \250\255\252\255\245\255\251\255\249\255\077\000\244\255\003\000 \030\000\031\000\160\000\235\000\054\001\129\001\204\001\023\002 \098\002\011\000\225\255\230\255\173\002\248\002\067\003\142\003 \217\003\036\004\111\004\186\004\005\005\080\005\155\005\230\005 \049\006\124\006\199\006\018\007\232\255\237\255\234\255\231\255 \236\255"; The extra whitespaces in the string constants are crucial. The intent of the output of ocamllex was that they would *not* be included in the strings, but cpp mangles those strings so that they are included in the strings, thereby producing a broken lexer. -=- ; Kenneth Oksanen, email: cessu@iki.fi, http://www.iki.fi/~cessu ((lambda(a) (a a((lambda(a)(lambda()(set! a(+ a 1))a))1)))(lambda(a c) ((lambda(b) (newline)(write b)(a a((lambda(c)(lambda()(c c)))(lambda(a) ((lambda(c) (if(=(modulo c b)0)(a a)c))(c))))))(c)))) ; Scheme me! ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners