Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6957463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:00:22+00:00 2026-05-27T15:00:22+00:00

Delphi Xe. In module Windows.pas I see one of methods: function InterlockedExchangeAdd(Addend: PLongint; Value:

  • 0

Delphi Xe.

In module Windows.pas I see one of methods:

function InterlockedExchangeAdd(Addend: PLongint; Value: Longint): Longint stdcall; overload;
{$EXTERNALSYM InterlockedExchangeAdd}
function InterlockedExchangeAdd(var Addend: Longint; Value: Longint): Longint stdcall; overload;
{$EXTERNALSYM InterlockedExchangeAdd}
...
function InterlockedExchangeAdd(Addend: PLongint; Value: Longint): Longint; external kernel32 name 'InterlockedExchangeAdd';
function InterlockedExchangeAdd(var Addend: Longint; Value: Longint): Longint; external kernel32 name 'InterlockedExchangeAdd';

Means, DLL can export functions with identical names.

I try to repeat:

I create the project

Program TestMyDll;

{$APPTYPE CONSOLE}

uses SimpleShareMem, SysUtils;

Function MyFunc(const X:Integer):string; StdCall; External 'MyDll.dll' Name 'MyFunc'; Overload;
Function MyFunc(const X:Extended):string; StdCall; External 'MyDll.dll' Name 'MyFunc'; Overload;

begin
  try
  Writeln;
  Writeln('MyDll test');
  Writeln('Int: ' + MyFunc(10));
  Writeln('Real: ' + MyFunc(10.55));
  Readln;
  except on E: Exception do Writeln(E.ClassName, ' : ', E.Message);end;
end.

It is compiled normally. Further I create DLL:

Library MyDll;

uses
  SimpleShareMem,
  DllUnit1 in 'DllUnit1.pas';

{$R *.res}

begin
//test
MyFunc(10);MyFunc(10.55);
end.

…and module DllUnit1.pas

Unit DllUnit1; Interface

Function MyFunc(const X:Integer):string; Overload; StdCall;
Function MyFunc(const X: Extended):string; Overload; StdCall;

Exports
MyFunc; // COMPILE ERROR

Implementation

Uses SysUtils;

Function MyFunc(const X:Integer):string;
begin
result:=Inttostr(x);
end;

Function MyFunc(const X: Extended):string;
begin
result:=Floattostr(x);
end;

end.

But at compilation I receive an error: [DCC Error] DllUnit1.pas(7): E2273 No overloaded version of ‘MyFunc’ with this parameter list exists.

In Delphi Help, I see:

"Delphi Language Reference"/"The exports clause"
...
When you export an overloaded function or procedure from a dynamically loadable library, you must specify its parameter list in the exports clause. For example,

exports
 Divide(X, Y: Integer) name 'Divide_Ints',
 Divide(X, Y: Real) name 'Divide_Reals';

On Windows, do not include index specifiers in entries for overloaded routines.

Questions:

  1. How correctly to export these functions in module DllUnit1 and whether it is possible to make it in general in Delphi (export under one name) to receive the same call from the my project TestMyDll as in the beginning (an example from windows.pas)?

  2. If such functions can be exported under one name, whether that it will be correct to work by call DLL from other languages (VB, C ++)? Or it is better to make two functions with different names?

P.S. Little bit similar question has found here (http://stackoverflow.com/questions/6257013/how-to-combine-overload-and-stdcall-in-delphi), but the answer did not suit me

P.S.S. Bad english


ADD (Has added after answers)

Clearly, thanks.

Has made so:

In the project:

Function MyFunc (const X:Integer):string; StdCall; External 'MyDll.dll' Name 'MyFunc'; Overload;
Function MyFunc (const X:Extended):string; StdCall; External 'MyDll.dll' Name ' MyFunc1'; Overload;

In DllUnit1

Exports
MyFunc (const X:Integer) Name 'MyFunc',
MyFunc (const X:Extended) Name 'MyFunc1';

It is compiled and works normally.

Still questions:

  1. Like works, but whether it is correct?

  2. Whether has value how to write “Function MyFunc (const X:Integer):string; Overload; StdCall;” or “Function MyFunc (const X:Integer):string; StdCall; Overload;”?

  3. This functions in project of other languages (Vb, C ++, C #) will be correctly caused?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:00:23+00:00Added an answer on May 27, 2026 at 3:00 pm

    Means, DLL can export functions with identical names.

    No, it does not. Delphi is declaring 2 overloads of InterlockedExchangeAdd() with different parameters, but kernel32.dll only exports one InterlockedExchangeAdd() function. The two Delphi declarations are importing the same DLL function. The overloaded parameters are equivilent when calling the function at runtime. In other words, Addend: PLongint and var Addend: Longint are identical as far as the function is concerned. At runtime, they are both a pointer to a Longint.

    The first declaration uses a C-style syntax for passing the Addend parameter by explicit pointer:

    var
      Value, Ret: Longint;
    begin
      Ret := InterlockedExchangeAdd(@Value, 1); 
    end;
    

    The second declaration uses a Delphi-style syntax for passing the Addend parameter by reference instead:

    var
      Value, Ret: Longint;
    begin
      Ret := InterlockedExchangeAdd(Value, 1); 
    end;
    

    When you export an overloaded function or procedure from a dynamically loadable library, you must specify its parameter list in
    the exports clause.

    I have never had to do that in my DLLs, but then I never export overloads, either. Specifying the parameters allows the compiler to differentiate which export uses which overload, but as the example also shows, those overloads are exported by different names, though they use the same name in the DLL’s coding.

    it is better to make two functions with different names?**

    Yes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Delphi XE. Windows 7. There is a function (please see a code below) or
Delphi 2009, among some cool stuff, has also just got Anonymous methods. I've seen
Delphi has a $WARN compiler directive that allows one to selectively enable or disable
Delphi 2010 has a nice set of new file access functions in IOUtils.pas (I
I have a Delphi Apache Shared Module. The base class is TWebModule. I can
After I ported Delphi Windows service app to FPC Linux console app I tried
I configure the recovery for Windows services to restart with a one minute delay
I have a Delphi 5 application in the application code calls a function in
I'm on Delphi 2009, and my application contains a data module, which has a
I am using Delphi 2010, latest version (from repository) of JEDI WinAPI and Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.