[M3devel] Constant to Constant?
Chris
Highjinks at gmx.com
Fri Mar 12 01:35:25 CET 2010
Things are progressing here, slowly but steadily.
I'm curious...
When writing an interface for something like this ...
/* C Type */
const C_Foo_t *Bar = get_foo_data(misc);
Is it better to do it this way...
<* EXTERNAL get_foo_data:C *>
TYPE Foo_Data = PROCEDURE(get_foo_data(somemisc : misctype) : C_Foo_t;
Or should I just do...
UNSAFE INTERFACE Foo;
(* Translating the C typedef struct over to Modula3 code. *)
TYPE C_Foo_T = UNTRACED REF RECORD .... END;
<* EXTERNAL get_foo_data:C *>
PROCEDURE get_foo_data(somemisc : misctype) : C_foo_t;
END Foo.
Main.m3
IMPORT Foo;
Foo_Data := Foo.get_foo_data(Misc);
END Main.
C_Foo_t is known, and has a Modula 3 representation in the Interface. But as the C Code shows, it has to be a constant value.
What's the best way to do this without hosing the Interface for everyone else that might want to use it? Variable expressions are no problem, it's making it a constant that's giving me trouble. It's constant because the data structure is managed by the supporting library, not by the Modula3 Code.
Tips...pointers?
--
Chris <Highjinks at gmx.com>
More information about the M3devel
mailing list