Problem with C function pointers
From: Andrew Skiba (skibochka_at_yahoo.com)
Date: 12/19/03
- Next message: Frode Tennebø: "Re: Ada200Y"
- Previous message: Simon Wright: "Re: load and use a ".o" file?"
- Next in thread: Stephen Leake: "Re: Problem with C function pointers"
- Reply: Stephen Leake: "Re: Problem with C function pointers"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 19 Dec 2003 14:13:53 -0800
Hello.
I'm writing a thin interface library to DirectFB. This library uses
structures with pointers to functions, emulating C++ vtables in C. The
addresses of those functions are set inside DirectFB, so those are not
valid Ada addresses. So, when I try to call such function (or assign
it to an access function variable), I get
raised CONSTRAINT_ERROR : dfb.adb:171 access check failed
The question is how do I eliminate the check? I'm using GNAT and the
declarations of relevant objects are:
type SetCooperativeLevel_func is access function
(thiz:IDirectFBCore_ptr; level:CooperativeLevel) return DFBResult;
pragma Convention (C, SetCooperativeLevel_func); -- this does not help
type IDirectFBCore is record
...
SetCooperativeLevel:SetCooperativeLevel_func; -- this field
-- points to some C function inside DirectFB library
...
end record;
pragma Convention (C, IDirectFBCore); -- this does not help, too :-(
thiz:IDirectFBCore;
f:SetCooperativeLevel_func;
f:=thiz.SetCooperativeLevel; -- here exception is raised
thiz.SetCooperativeLevel (...); -- or here exception is raised
The situation remains the same if I make Unchecked_Conversion, still I
have to call a function some time, and then the exception will be
raised anyway.
Any suggests will be appreciated.
Regards,
Andrew Skiba
- Next message: Frode Tennebø: "Re: Ada200Y"
- Previous message: Simon Wright: "Re: load and use a ".o" file?"
- Next in thread: Stephen Leake: "Re: Problem with C function pointers"
- Reply: Stephen Leake: "Re: Problem with C function pointers"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]