[M3devel] open array parameter passing, to external C procedure
Mika Nystrom
mika at async.caltech.edu
Mon Feb 6 14:40:29 CET 2012
I don't think it's going to work. The Modula-3 compiler usually inserts
metadata at ADR(x) where x is an array of any type.
I know using ADDRESS works for the declaration, and then ADR(events[0])
for passing. No need for SIZE, though.
If you like the type checking (we do, right?) you can of course
encapsulate it in a layer of UNSAFE Modula-3 with a safe interface.
Mika
=?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?= writes:
>I have this case:
>
>extern int epoll_wait (int __epfd, struct epoll_event *__events,
> int __maxevents, int __timeout);
>
>And I would like to do it like:
>
><*EXTERNAL*>=20
>PROCEDURE epoll_wait (epfd: int; VAR events: ARRAY OF epoll_event; =
>timeout: int :=3D -1): int;
>
>=85
>VAR
> events: ARRAY [0..MaxEvents-1] OF epoll_event;
>
>=85
>
>WITH res =3D epoll_wait(epfd, events, 2) DO
> =85
>END;
>
>Can I expect cm3 to do "right thing". Or I have to place parameters "by =
>hand" using ADR and SIZE?
>
>TIA,
>dd
More information about the M3devel
mailing list