From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id A783BBC58 for ; Wed, 15 Sep 2010 23:14:52 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.56,372,1280700000"; d="scan'208";a="67656500" Received: from mail-qy0-f173.google.com ([209.85.216.173]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 15 Sep 2010 23:14:52 +0200 Received: by qyk34 with SMTP id 34so5722848qyk.18 for ; Wed, 15 Sep 2010 14:14:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.215.137 with SMTP id he9mr1542818qcb.149.1284585291044; Wed, 15 Sep 2010 14:14:51 -0700 (PDT) Received: by 10.229.85.196 with HTTP; Wed, 15 Sep 2010 14:14:51 -0700 (PDT) In-Reply-To: <20100915192954.GA8555@yeeloong> References: <20100915192954.GA8555@yeeloong> Date: Wed, 15 Sep 2010 23:14:51 +0200 Message-ID: Subject: Re: [Caml-list] Checking for caml version from C From: Kaustuv Chaudhuri To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=UTF-8 X-Spam: no; 0.00; ocaml:01 ocaml:01 ocamlc:01 -version:01 ocamlc:01 -version:01 command-line:01 wrote:01 preprocessor:01 caml-list:01 minor:01 minor:01 caml:02 checking:02 -ccopt:03 On Wed, Sep 15, 2010 at 9:29 PM, wrote: > I'd like to know if there is a standard way to check for > Ocaml version with the C preprocessor Not sure about standard ways, but here's one ugly way: % cat ugly.c #if OCAML_MAJOR == 3 && OCAML_MINOR == 12 Hello 3.12 world #else Hello non-3.12 world #endif % ocamlc -version 3.12.1+dev4 (2010-09-03) % ocamlc \ -ccopt -DOCAML_MAJOR=`ocamlc -version | cut -d'.' -f1` \ -ccopt -DOCAML_MINOR=`ocamlc -version | cut -d'.' -f2` \ -ccopt -E \ ugly.c # 1 "ugly.c" # 1 "" # 1 "" # 1 "ugly.c" Hello 3.12 world (Drop the -ccopt -E option when you use it, obviously.) -- Kaustuv