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
[Caml-list] Linear constraints
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] Using Ocaml keywords as structure members.
> I am interesting in converting a data-structure from 
> C to Ocaml using CamlIdl. I am running into some 
> trouble because one of the structure members is 
> named "end". 
> Apart from renaming the structure member in 
> C (3rd party, lotsa work!), is there anything else
> that I can do?

Yes: use the "mlname" attribute.  In the IDL file:

struct a_test {
  int start;
  [mlname(end_)] int end;

> A common C coding convention is to use
> struct definitions of the form - 
> <test.idl> ---------
> typedef struct a {
>   int x;
>   int y;
> } a;
> </test.idl> --------
> Using CamlIdl, this results in a conversion to [incorrect Caml code]

I'd suggest to change the IDL file (and only the IDL file) to either

   typedef struct {
     int x;
     int y;
   } a;
   // use "a" instead of "struct a" everywhere else


   struct a {
     int x;
     int y;
   // use "struct a" instead of "a" everywhere else

Note that I'm not suggesting you do this change in the .c and .h
sources for the original C code.  IDL descriptions can (and often need
to) omit some aspects of the C interface they describe.

- Xavier Leroy

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: