Hello Lovelies! (I have no idea what to call “us” lol)
So I am designing a thin exported FFI for an IPC-like client to hook into my engine. I tend to use GNATStudio and check semantics to at least dry check before I try to compile and I felt I need to ask how “valid” said code exists? I assume if the inverse (import) were to be done, then GPRBuild would look for linking with C/C++ symbols statically/dynamically, right?
EDIT: Also anyone reading this, merry christmas/happy holidays! It is late but it is still nice to say!
I first tried the usual
with Interfaces.C;
package GBox is
procedure InitClient
with Export => True,
Convention => C,
External_Name => “initclient”;
end GBox;
So this works fine. C_Plus_Plus also works. I am wondering when export with C++ if there is any gotchas. I plan to mostly stick to C so I was just curious. I attached the GNATStudio semantic check command. It works with C/C_Plus_Plus, COBOL and so on. It checks an error if I try something like C_Minus_Minus. If you have convention C_Plus_Plus; Does this exported function have C++ style like name mangling/linking rules?
gprbuild -q -c -f -gnatc -u -P/home/nicolterra/Documents/GHProjs/Shrine/shrine.gpr gbox.ads
[2025-12-26 06:18:29] process terminated successfully, elapsed time: 00.10s
And I suppose on that note, I am going to have this exported FFI be C, so I mostly just wanted to ask and potentially not get a hallucinated response from an LLM. But since you can do C_Plus_Plus I was wondering what the use cases/limits were.
If you can point me generously into a project/documentation definition to read as well, that would be super nice! Basically my question is: “if you can export/import with convention C_Plus_Plus, why not just default to it and not C? Is it just because C actually has a stable ABI and it is easier to document/write an example for?”
Thank you for indulging my curiosity! I look forward to reading more replies and more information!