Page 1 of 1

Mapping opaque pointers

Posted: Thu Apr 07, 2016 12:42 pm
by dmaksimiuk
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

Re: Mapping opaque pointers

Posted: Sat Apr 09, 2016 7:49 pm
by Ivan Denisov
I am not sure about the answer, however there is automatic C-headers translator called H2O.

It returns next structure.

Code: Select all

  MyDataStruct_t_tag* = RECORD END;
  PtrToMyDataStr* = POINTER TO MyDataStruct_t_tag;