cdecl directive (Was: Re: [fpc-devel]Bugs in DosCalls.pas)

XHajT03 at mbox.vol.cz XHajT03 at mbox.vol.cz
Thu Oct 26 22:21:02 CEST 2000


Date sent:      	Tue, 24 Oct 2000 22:11:00 +0900
From:           	KO Myung-Hun <komh at chollian.net>
To:             	FPC mail <fpc-devel at lists.freepascal.org>
Subject:        	[fpc-devel]Bugs in DosCalls.pas
Send reply to:  	fpc-devel at deadlock.et.tudelft.nl

   Hi,

> function DosDevIOCtl(Handle,Category,Func:longint;var Params;
>                      ParamLen:longint;var ParamSize:longint;
>                      var Data;DataLen:longint;var DataSize:
>                      longint):longint; cdecl;

 you're absolutely right here, I'm changing it now.

> Second is DosSetFilePtr function. Original functions from DOSCALL.DLL
> must be declared 'cdecl' model. But helper(?) function is not. In
> addtion, in case of DosSetFilePtr, If DosSetFilePtr helper function is
> declared 'cdecl', then programs calling DosSetFilePtr encounter
> SYS3171 error.

 This is somewhat more complicated as I found now. Your solution 
(removing cdecl for the helper) solves the immediate problem, so I'm 
applying it now as well. However, the reason of the problem is 
somewhat wider (I'm sending a copy of this message to the core 
developers' list as well so that people not reading this list 
regularly can join the discussion).
 What's the matter - cdecl causes not only a different calling 
convention to be used, but prevents the normal identifier name 
"encoding" as well. For example the identifier of the DosSetFilePtr 
function is internally encoded into 
_DOSCALLS$$_DOSSETFILEPTR$LONGINT$LONGINT, whereas with the cdecl 
modifier, just _DosSetFilePtr is used. However, this is the same as 
the name of the original (overloaded) function imported from the DLL. 
This behaviour is wrong in my opinion. First, there's no warning 
about the double declaration. However, I don't see a reason for using 
non-encoded identifiers at all in functions/procedures those are not 
imported and not declared as exported either. I think we should 
introduce some other modifier for cases when the programmer wants to 
allow this behaviour (non-encoded names) explicitly.
 I don't know how Delphi solves this problem (if it supports 
something like cdecl at all), but at least Virtual Pascal does 
exactly this (well, it's less convenient there, since one has to 
disable the encoding even for imported functions manually, but that's 
another story).
 Your opinions?

                      Have a nice day


                              Tomas Hajny, XHajT03 at mbox.vol.cz on Internet
                                           tom.sms at axon.cz in urgent cases




More information about the fpc-devel mailing list