On 29 Sep 2008, at 16:04, EarMaster - Bent Olsen wrote:

I use Xcode to find samples of codes and try to make it work on FPC/ Lazarus. One example opens an AUGraph and send MIDI messages - a small sample. It
calls AUGraphNewNode which returns a node from 1 to n, and it works
perfectly in FPC on Carbon/i386, and of course for Xcode on the same
machine.

The same code works fine in Xcode on Carbon/PowerPC, but does not return any
nodes in FPC on Carbon/PowerPC.

// -------- Code snips

// Pascal
type
 ComponentDescription = record
   componentType: OSType;
   componentSubType: OSType;
   componentManufacturer: OSType;
   componentFlags: UInt32;
   componentFlagMask: UInt32;
 end;

function AUGraphNewNode(inGraph: AUGraph; const inDescription:
ComponentDescription;
inClassDataSize: LongWord; inClassData : Pointer; var outNode : AUNode):
OSStatus;
 external name '_AUGraphNewNode'; mwpascal; //
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;

"const inDescription: ComponentDescription" is wrong, because FPC does not guarantee that this will be passed by reference (especially in case of C imports, because in C "const" also means "pass by value"). Either use a pointer type, or use "var" instead. There is no constvar or similar specifier.

Also add {$packrecords C} to your source to ensure that the records are properly packed, and translate "unsigned long" using the "culong" type from the ctypes unit rather than using uint32 ("unsigned long" is not the same as uint32 on all platforms, e.g. it's different on 64 bit Mac OS X).


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to