Reputation:
I need to use the Ada library from Lua. I want to use a generic package, which, along with other data, will contain a function that will register in Lua with different names depending on the data. As I understand it, I should declare this function as "with Export, Convention => C", but when instantiating several instances of such a package, the library will contain several functions with the same names and it will not compile. Is it possible in such a situation not to use "Export", but only the "Convention => C", because only a function reference is used for registration in Lua?
with System; use System;
with Interfaces.C; use Interfaces.C;
generic
type Data is private;
Name : String;
package P is
function Call (Lua : Address) return int
with Export, Convention => C;
function Get_Name return String is (Name);
end P;
Upvotes: 4
Views: 211
Reputation: 39668
You only need Export
if the function needs to be visible to a linker (for example, when you have C code explicitly calling this function). If you only need to pass the function via pointer into the Lua runtime, Convention => C
on the function suffices, though you also need another Convention => C
on the function pointer type.
Upvotes: 4