Apologies, I should have read your bug report before replying as I didn't realise your problem was with the flat call to fb_get_master_interface. I just assumed that you would be getting a problem with the call to GetVersion.
I have put your Pascal example into my test system and got an Access Violation error when IMaster.GetVersion is called. Looking at the code, you may be a bit hopeful in giving the return type of GetMaster as IMaster - FPC may assume too much from this. I changed it to: function GetMaster: Pointer; cdecl; external 'libfbclient.so' name 'fb_get_master_interface'; to get back a simple pointer and then coerced the result to IMaster as master := IMaster(GetMaster()); The program now does complete without an error, but returns "15" as the version. My reading of the Firebird code is that the correct result is 4. So still something not right - probably the way the instance variable is passed. Using the lazarus disassember, the call to fb_get_master_interface now looks like this i.e. much more like a cdecl call returning a simple type. 00000000004003D4 48c7042590ba650078563412 movq $0x12345678,0x65ba90 project1.lpr:24 master := IMaster(GetMaster()); 00000000004003E0 e83bffffff callq 0x400320 <fb_get_master_interface@plt> 00000000004003E5 48a390ba650000000000 movabs %rax,0x65ba90 Interestingly, if I change the coercion to master := TObject(GetMaster()) as IMaster; It gives me an access violation on the call to GetMaster - or at least the internal call that validates the interface - so there really is something different between the two structures. On 14/08/14 14:56, Dimitry Sibiryakov wrote: > 14.08.2014 14:08, Tony Whyman wrote: >> I'm not quite sure what you think is wrong with this code (from the fpc >> viewpoint): > That code is fine. This isn't: > > call fb_get_master_interface > movq -104(%rbp),%rax > movq %rax,U_P$CREATE_MASTER > > As you can see, value returned by function in %rax is overwritten before > it get > assigned to the variable. > ------------------------------------------------------------------------------ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel