[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RFC: Support non-standard extension (call via casted function pointer)



> > 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;

BTW the proper idiom would be instead:

       function Foo_2 return Integer;
       pragma Import (C, Foo_2, "foo");

to import the same C function with two different types.

But as Eric said, users should use this at their own risk, and only on truly
compatible types, otherwise this is non portable and may break across compilers
or versions.

Arno


Reply to: