Replies: 3 comments
-
To call C functions you use the EXTERNAL pragma It can be used to reference an entire interface as in <EXTERNAL> INTERFACE LLVM; (* lots of declarations - all of which are external *) or to declare an individual external procedure, constant or variable as in INTERFACE SomeInterface <*EXTERNAL UnixName : C *> PROCEDURE LocalName(someparm : INTEGER) : BOOLEAN; The ":C" can be omitted and the system uses the default external language. (which is C the only language) A call to SomeInterface.LocalName(99); for example will call UnixName in some library or object which is linked in. If the name in the EXTERNAL pragma is absent the local name use used. |
Beta Was this translation helpful? Give feedback.
-
Also, you can use the declarations in m3-libs/m3core/src/C/Common/Ctypes.i3
for the parameter types. These are Modula-3 type declarations designed
to be binary-identical to various types in C. They refer indirectly to
other interfaces, in an effort to make them platform-independent, largely
successfully, I believe. You can use them to refer to global variables
as well.
…On 9/8/22 09:22, peter mckinna wrote:
To call C functions you use the EXTERNAL pragma
It can be used to reference an entire interface as in
</EXTERNAL/> INTERFACE LLVM;
(* lots of declarations - all of which are external *)
END LLVM.
or to declare an individual external procedure, constant or variable as in
INTERFACE SomeInterface
<*EXTERNAL UnixName : C *> PROCEDURE LocalName(someparm : INTEGER) : BOOLEAN;
<*EXTERNAL ErrorNo *> VAR err : [0.255];
END SomeInterface.
The ":C" can be omitted and the system uses the default external language. (which is C the only language)
A call to SomeInterface.LocalName(99); for example will call UnixName in some library or object which is linked in.
Similarly for SomeInterface.err;
If the name in the EXTERNAL pragma is absent the local name use used.
—
Reply to this email directly, view it on GitHub <#1059 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABSVZNFT6WE22OWI3O5E7YDV5HZBXANCNFSM6AAAAAAQGJ5MDQ>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
It's easy. Make an interface with pragma <*EXTERNAL*>
Example
https://github.com/modula3/cm3/blob/master/m3-libs/m3core/src/coroutine/UCONTEXT/ContextC.i3
Compare
https://github.com/modula3/cm3/blob/master/m3-libs/m3core/src/coroutine/UCONTEXT/ContextC.c
Mika
…On Wed, Sep 7, 2022, 3:08 AM pwd96m4a ***@***.***> wrote:
Something like this?
https://www.nongnu.org/gm2/11/interface_to_c.html
Is it possible? What's the syntax? I prefer writing by hand like I could
do with gm2 instead of relying on demoitem's swig for cm3.
—
Reply to this email directly, view it on GitHub
<#1059>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKYNJJSILI6G2YTOWNMMYTV47TKLANCNFSM6AAAAAAQGJ5MDQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Something like this?
https://www.nongnu.org/gm2/11/interface_to_c.html
Is it possible? What's the syntax? I prefer writing by hand like I could do with gm2 instead of relying on demoitem's swig for cm3.
Beta Was this translation helpful? Give feedback.
All reactions