On 01/27/2016 04:17 PM, Richard Biener wrote: > We are trying to support > > t.c > --- > void *foo(); > > int bar() > { > return ((int (*)())foo) (); > } > > t2.c > ----- > int foo () { return 0; } > > thus doing a direct call to a function with a (wrong) prototype via a function > pointer cast to the correct type and having a matching implementation of > that function elsewhere.
I suspect Ada needs something like this already. I expect the following to work (although it is quite hideous). with System; package Import is function Foo return System.Address; pragma Import (C, Foo); function Bar return Integer; end Import; package body Import is function Bar return Integer is function Foo_2 return Integer; pragma Import (C, Foo_2); for Foo_2'Address use Foo'Address; begin return Foo_2; end Bar; end Import; Florian