I have a SOAP Data Module that exports this function
function MyFunction(MyParam1, MyParam2): boolean; stdcall;
I can use this function from another exe. Everything works.
Now I want to use the same function from inside the same project it’s in. I added its unit to the uses clause but it didn’t recognise it (I got Undeclared Identifier). Then I added an overload but I can’t get it to work.
function MyFunction(MyParam1, MyParam2): boolean; stdcall; overload;
function MyFunction(MyParam1, MyParam2): boolean; overload;
I get “field definitions not allowed…”
I want to be able to access the function from outside using stdcall, but also internally like common library function calls. Does anyone know how I can achieve that?
Your problem has nothing to do with the calling convention.
A few things to notice:
A silly bug
First,
is a syntax error. You have forgotten to specify the types of
MyParam1andMyParam2.Visibility
Consider the unit
Only
Func1will be visible to other units, because onlyFunc1is declared in theinterfacesection. And the interface is what other units see.Calling conventions
You can use
stdcallinside your own project. That isn’t a problem at all. You will probably not even notice that the function has an ‘unusual’ calling convention.Overloaded functions
A pair of overloaded functions (procedures) is a pair of functions (procedures) with the same name but with different parameter lists, as in
Two functions cannot have the same name and parameter lists, even if they are overloaded. Indeed, if that was allowed, then how in the world would the compiler know what function you want to call?!