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
C-like macros in OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-06-26 (22:00)
From: Raj B <rajb@r...>
Subject: C-like macros in OCaml
Hi there

Is there any way I can achieve the use of C-like preprocessor macros  
in OCaml?

#define FOO 1


I am using an array of bits (a bitset) where each bit represents a  
flag, and i would like to
access this set by using names rather than remembering which index in  
the array represents which flag.

Similarly, is there any way of getting a C-like enumeration? e.g.

enum days {Mon = 1, Tue, Wed...}

I guess that OCaml does not provide these by default, but I wonder if  
someone has done some camlp4 magic
to use these.