[fpc-pascal] MacOS and Opaque types

Bent Normann Olsen bent at earmaster.com
Fri Feb 22 11:18:43 CET 2008


Thanks, that I can understand. I will give it a go, and see how far I get
;-)

Kind regards

-----Original Message-----
From: fpc-pascal-bounces at lists.freepascal.org
[mailto:fpc-pascal-bounces at lists.freepascal.org] On Behalf Of Jonas Maebe
Sent: 22. februar 2008 11:10
To: FPC-Pascal users discussions
Subject: Re: [fpc-pascal] MacOS and Opaque types


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
_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal




More information about the fpc-pascal mailing list