Another problem, also reported on the macpascal mailing list and reproduced by the following program: [G5:gcc/p/test] adriaan% cat avo12.pas program avo12; type Str255 = record sLength: Byte; sChars: packed array[1..255] of char; end; function StringToStr255 ( const s: String ) = Result : Str255; begin Result.sLength := Min( Length( s ), 255 ); if Result.sLength > 0 then begin Result.sChars[1..Result.sLength] := s[1..Result.sLength]; end; end; procedure DrawString1( const s: Str255); external name 'DrawString'; procedure DrawString2( protected var s: Str255); external name 'DrawString'; begin DrawString1( StringToStr255( 'Hello')); {OK} DrawString2( StringToStr255( 'Hello')) {Error: reference expected, value given} end. [G5:gcc/p/test] adriaan% gpc avo12.pas avo12.pas: In main program: avo12.pas:19: error: reference expected, value given In gpc-20030830, this was no problem, but now it is no longer allowed, which is quite inconvenient. In the GPC interfaces for Mac OS X, we use the external declaration form with a "protected var" because (according to the gc docs) the "const" declaration form doesn't guarantuee that the parameter is passed by reference, which is an ABI requirement. Regards, Adriaan van Os
participants (5)
-
Adriaan van Os -
Frank Heckenbach -
Peter N Lewis -
Prof A Olowofoyeku (The African Chief) -
Waldek Hebisch