howto embed felix in c++

6 views
Skip to first unread message

Costantino Giuliodori

unread,
Sep 18, 2009, 4:20:17 AM9/18/09
to felix-l...@googlegroups.com
hi, 
I am writing because I find that felix is a great project and I remained stunned by the result. 

I'm a newbie and I don't know ocaml.
I would ask how to incorporate felix in a c++ program.

In particular I was thinking about how to create felix objects 
within the main function. 
As I said I am a novice and I would 
appreciate even a RTFM.

thanks
--
Costantino Giuliodori

john skaller

unread,
Sep 18, 2009, 7:25:09 AM9/18/09
to felix-l...@googlegroups.com

On 18/09/2009, at 6:20 PM, Costantino Giuliodori wrote:
>
> I would ask how to incorporate felix in a c++ program.

This is probably very hard. It is much easier to incorporate
C++ into Felix than the other way around.

At present, for Felix to generate a "pure library" which can be
called by C++ would require some (minor) modifications to
the compiler.

It is not impossible to call Felix from C++, just difficult. To do it
you have to do much the same as most interpreters: initialise
some objects and then call a processing function. However all
this is already done by the C++ mainline program "flx_run"
or "flx_arun".

With some care you can ensure you only generate C callable
functions. Since Felix *always* generates a library not a program,
these can simply be called from C++. The main problem with this
is that Felix generates C structs containing C structs etc all of which
are named by Felix, and it is very hard to "import" and use these type
names into a C++ program. The names are based on an integer counter
and so they change with even small modifications to the Felix code.

You CAN tell Felix to typedef these names to what you want,
but you have to do that "recursively" for all contained types,
and you still HAVE to import the generated C++ header file.


--
john skaller
ska...@users.sourceforge.net


Reply all
Reply to author
Forward
0 new messages