Hi,
in C there is something called an opaque pointer (https://en.wikipedia.org/wiki/Opaque_pointer):
typedef struct MyDataStruct_t *PtrToMyDataStr;
which allows to hide any implementation details of MyDataStruct.
I need to write a BBox interface to a DLL that uses this approach.
I am not sure if I should do something like this:
TYPE MyDataStruct_t* = INTEGER;
or
TYPE MyDataStruct_t* = POINTER [untagged] TO RECORD END;
and the in an interfacing procedure
PROCEDURE DoSomethig*["MyDll"](VAR [nil] PtrStruct : MyDataStruct_t ....)
Any experience with mapping of this construct? How it should be implemented?
Cheers,
Darek
Mapping opaque pointers
-
- Posts: 28
- Joined: Sun Jun 14, 2015 3:56 pm
- Location: Delft, The Netherlands
- Ivan Denisov
- Posts: 362
- Joined: Tue Sep 17, 2013 12:21 am
- Location: Krasnoyarsk, Russia
Re: Mapping opaque pointers
I am not sure about the answer, however there is automatic C-headers translator called H2O.
It returns next structure.
It returns next structure.
Code: Select all
MyDataStruct_t_tag* = RECORD END;
PtrToMyDataStr* = POINTER TO MyDataStruct_t_tag;