Skip to content Skip to sidebar Skip to footer

Preventing Mangled Names In Ada Dll

Is there a simple way to prevent Ada names from getting mangled when creating an Ada DLL? Here is my .adb code with Ada.Text_IO; package body testDLL is procedure Print_Call is

Solution 1:

You can control the object name via the Link_Name and External_Name parameters of the pragma, writing it like so:

pragma Export(C, Print_Call, "Print_Call", "Print_Call");

Alternatively, if you're using Ada2012 you can use aspects to specify these:

functionAdd_Nums(A,B : in Integer) returnIntegerwithExport, Convention =>Ada, Link_Name =>"Add_Nums";

The following covers Ada's interfacing pragmas: http://www.ada-auth.org/standards/12rm/html/RM-J-15-5.html

This thread covers a little discussion revealing the differences of the two: https://groups.google.com/forum/?fromgroups=#!searchin/comp.lang.ada/opengl/comp.lang.ada/6IVlMbtvrrU/mv3UUiDg5RwJ

Solution 2:

Apparently (section 77) the convention DLL is a synonym for StdCall, which I understand to result in the sort of name mangling you report.

You may do better with convention C:

pragma Export(C, Print_Call, "Print_Call");

or even

pragma Export(C, Print_Call);

(but then the link name will be in lower case, so you'd need to change the Python getattr() call).

I'm assuming that there's no difference in the way the calling sequences handle the stack/parameters.

Post a Comment for "Preventing Mangled Names In Ada Dll"