Q:

Ada Access to parameterless procedure "wrong convention"

I have the following binding:
function atexit(proc : access Procedure) return Integer with
    Import, Convention => C;

As well as the procedure:
procedure Exiting is
begin
    Put_Line("Exiting");
end Exiting;

When I try to call it like:
I : Integer := atexit(Exiting'Access);

it fails with subprogram "Exited" has wrong convention
however providing my own (incompatable) atexit which accepts a parameter, and modifying Exiting to use that same parameter, allows passing the procedure just fine.
So it seems like the issue is passing a parameterless procedure as an access type.
I've tried giving a named access type like
type Procedure_Access is access Procedure;

But the result is exactly the same.
How can I pass a parameterless procedure then?

A:

You might have forgotten the Convention aspects in the declarations of Exiting and Procedure_Access. The following works in GNAT CE 2018:
foo.c
int _atexit(void (*f)(void))
{
  (*f)();
  return 0;
}

main.adb
with Ada.Text_IO;  use Ada.Text_IO;
with Interfaces.C; use Interfaces.C;

procedure Main is

   type proc_ptr is access procedure
     with Convention => C;

   function atexit(proc : proc_ptr) return int
     with Import, Convention => C, Link_Name => "_atexit";

   procedure Exiting
     with Convention => C;      

   procedure Exiting is
   begin
      Put_Line("Exiting");
   end Exiting;

   I : Integer := Integer (atexit (Exiting'Access));

begin
   Put_Line("atexit returned " & I'Image);
end Main;

default.gpr
project Default is

   for Source_Dirs use ("src");
   for Object_Dir use "obj";
   for Main use ("main.adb");
   for Languages use ("Ada", "C");

end Default;

output
Exiting
atexit returned  0

