[fpc-pascal] MacOS and Opaque types

Jonas Maebe jonas.maebe at elis.ugent.be
Fri Feb 22 11:09:47 CET 2008


On 22 Feb 2008, at 11:04, Bent Normann Olsen wrote:

> I'm new to Mac development environment, and I was looking thru the
> CoreMIDI/MIDIServices.h, to see how much work it's going to take (at  
> least
> maybe partially) to implement some of the functions to own projects.  
> I hit
> the wall with some typedef, for example "struct OpaqueMIDIClient *
> MIDIClientRef", and I now understand that Apple do not always want
> developers to know what is behind some type definitions. Is this true?

Yes. This is not Apple-specific, this is a basic way of information  
hiding which is regularly used in C.

> How can one come about this? I'm really open to any suggestions.

You don't need the contents (C programs don't have access to them  
either). As far as the declaration goes in Pascal, just do something  
like

type
   POpaqueMIDIClient = ^OpaqueMIDIClient;
   OpaqueMIDIClient = record
   end;

var
   MIDIClientRef: POpaqueMIDIClient;


Or you could even declare MIDIClientRef as a plain untyped pointer  
(although you'll lose some type checking when using {$t+} in that case).


Jonas



More information about the fpc-pascal mailing list