English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] pa_macro to substitute a constant?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-08-27 (16:32)
From: Richard Jones <rich@a...>
Subject: [Caml-list] pa_macro to substitute a constant?

How can I use pa_macro to substitute in a constant into a program?

A real example:

Makefile ------------------------------------------------------------

PACKAGE = foo
VERSION = 1.0.0

version.cmo: version.ml Makefile
	ocamlc -I +camlp4 -pp 'camlp4o pa_macro.cmo -DPACKAGE="$(PACKAGE)" -DVERSION="$(VERSION)"' $< -o $@

version.ml ----------------------------------------------------------

let package = PACKAGE
let version = VERSION

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

Needless to say this example doesn't work, and looking at the thin
documentation for pa_macro, I'm not even sure it's possible.  Is it?

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
MONOLITH is an advanced framework for writing web applications in C, easier
than using Perl & Java, much faster and smaller, reusable widget-based arch,
database-backed, discussion, chat, calendaring:
http://www.annexia.org/freeware/monolith/