On Sun, 29 Aug 2010, Jonas Maebe wrote:


On 29 Aug 2010, at 16:10, Michael Van Canneyt wrote:

What does stdcall calling convention currently do on non-windows platforms ?

The same as on Windows.

But we are under no obligation to have this so ?

Does a C compiler (gcc) under linux understand 'stdcall' ?

I think that having to write
 {$ifdef windows}const{$else}constref{$endif} myarg: mytype
for possibly thousands of arguments in an interface description is simply not
an option.

That would not be necessary:
a) constref would be correct both for Windows and non-Windows

Yes, but is unusable in the cases where source code is shared between Delphi 
and FPC, such as the Gecko sources.

I simplified the example, maybe the following would have been more clear:

{$ifndef fpc}const{$else}constref{$endif} myarg: mytype

I implicitly assumed that FPC would be used for any non-windows platform.

b) I'm not aware of a single routine that uses stdcall on non-Windows, other 
than the AddRef and ReleaseRef routines mentioned at the start of this 
discussion

Well, there are in the Gecko interface:

sEnumerators.pas:    function HasMoreElements(out _retval: PRBool): nsresult; 
stdcall;
nsEnumerators.pas:    function GetNext(out _retval: nsISupports_std19): 
nsresult; stdcall;
nsErrorUtils.pas:                aStringBundleURL: PAnsiChar): nsresult; 
stdcall;
nsErrorUtils.pas:                aErrorModule: PRInt16): nsresult; stdcall;
nsErrorUtils.pas:                out aResult: PAnsiChar): nsresult; stdcall;
nsErrorUtils.pas:                aStringBundleKey: PAnsiChar): nsresult; 
stdcall;
nsErrorUtils.pas:                aError: nsresult): nsresult; stdcall;
nsErrorUtils.pas:                out aResult: PAnsiChar): nsresult; stdcall;
nsInit.pas:    function CallMethod(aMethodIndex: PRUint16; const aInfo: 
XPTMethodDescriptor; aParams: PXPTCMiniVariantArray): nsresult; stdcall;
nsInit.pas:  XPCOMExitRoutine = function : Longword; stdcall;
nsInit.pas:  nsIDirectoryServiceProvider_stdcall = interface(nsISupports)
nsInit.pas:    function GetFile(const prop: PAnsiChar; out persistent: PRBool; 
out AFile: nsIFile): nsresult; stdcall;
nsInit.pas:                                  
nsIDirectoryServiceProvider_stdcall)
nsInit.pas:    function GetFile(const prop: PAnsiChar; out persistent: PRBool; 
out AFile: nsIFile): nsresult; stdcall;
nsThreadUtils.pas:    function acceptEvent(aEvent: nsIRunnable): PRBool; 
stdcall;
nsXPCOM.pas:                                out aWriteCount: PRUint32): 
nsresult; stdcall;
nsXPCOM.pas:                               out aReadCount: PRUint32): nsresult; 
stdcall;
nsXPCOM.pas:    function Alloc(size: size_t): Pointer; stdcall;
nsXPCOM.pas:    function Realloc(ptr: Pointer; newSize: size_t): Pointer; 
stdcall;
nsXPCOM.pas:


If you want to apply a custom calling convention to an entire file, that is 
also already supported using {$calling xxx} (which I'm not very fond of either).

But that is only if none is specified explicitly ?

In each case, a question to Joost is: Why does he need to change IInterface 
calling convention ?
I see no code in the Gecko/XPCom units that would require this ? Because if it doesn't need to be changed, the whole discussion is academic.

Michael.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to