comp.lang.ada
 help / color / mirror / Atom feed
* Problem with C function pointers
@ 2003-12-19 22:13 Andrew Skiba
  2003-12-20  2:07 ` Stephen Leake
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Skiba @ 2003-12-19 22:13 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-12-23 16:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-19 22:13 Problem with C function pointers Andrew Skiba
2003-12-20  2:07 ` Stephen Leake
2003-12-21 13:06   ` Andrew Skiba
2003-12-21 14:04     ` Stephen Leake
2003-12-22  9:37       ` Andrew Skiba
2003-12-22 23:10         ` Stephen Leake
2003-12-23 16:04           ` Ad Buijsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox