From: skibochka@yahoo.com (Andrew Skiba)
Subject: Problem with C function pointers
Date: 19 Dec 2003 14:13:53 -0800
Date: 2003-12-19T14:13:53-08:00 [thread overview]
Message-ID: <963c4dec.0312191413.15c9cb08@posting.google.com> (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
next reply other threads:[~2003-12-19 22:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-19 22:13 Andrew Skiba [this message]
2003-12-20 2:07 ` Problem with C function pointers 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox