I used this pragma to import getpid from C:
function Get_Process_ID return Process_ID;
pragma Import (C, Get_Process_ID, "getpid");
I expected this to be a little harder. To use getpid in C, I need to explicitly include the header file unistd.h; in the above pragma, I made no reference to a header file. How does GNAT know exactly where to find getpid?
Edit:
Here's a minimum working example:
with Ada.Text_IO;
procedure Main is
subtype Process_ID is Integer;
function Get_Process_ID return Process_ID;
pragma Import (C, Get_Process_ID, "getpid");
begin
Ada.Text_IO.Put_Line (Process_ID'Image (Get_Process_ID));
end Main;
Saved as main.adb, this compiles with the following command:
gnat make main.adb
I'm using a fresh install of the gnat package from the Ubuntu 18.04 software repositories with no configuration or project files. The GNAT version is 7.5.0.