Re: Mathlink: How do I pass arbitrary data from Mathematica to C?
- To: mathgroup at smc.vnet.net
- Subject: [mg86946] Re: Mathlink: How do I pass arbitrary data from Mathematica to C?
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Thu, 27 Mar 2008 08:16:09 -0500 (EST)
- References: <fs4rmb$p3s$1@smc.vnet.net> <fs7ilu$gll$1@smc.vnet.net> <fsd6e6$98p$1@smc.vnet.net>
Hi, > Do you have an example of this, where the format of the data is not > known in advance? Do you think this is a Mathematica problem ? It is up to *you* to set up your data structure. But typedef struct Atom { int what; union { long int N; double D; struct Symbol *S; } Entry; } Atom; may do that. And your data structure may be typedef struct Expression { int what; union { Atom *atm; struct { struct Expression *First; struct Expression *Rest; } List; } Entry; } Expression; clearly you need a symbol table and more data types than long int and double, rationals and complex may be added. It *must* be considered just a collection of bytes > of data. The data can be any length from one byte to about a MB. It > might be binary data, but will probably be text. > The data will be passed to some hardware. The format of the data > depends on the hardware. Hence I just want to pass what is a > collection of bytes. I cant assume they will be integers (they might > be), I cant assume they will be floating point values (they might > be). > Regards Jens