From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,27200915cbff176,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-19 14:13:53 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: skibochka@yahoo.com (Andrew Skiba) Newsgroups: comp.lang.ada Subject: Problem with C function pointers Date: 19 Dec 2003 14:13:53 -0800 Organization: http://groups.google.com Message-ID: <963c4dec.0312191413.15c9cb08@posting.google.com> NNTP-Posting-Host: 212.199.154.54 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1071872033 25247 127.0.0.1 (19 Dec 2003 22:13:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 19 Dec 2003 22:13:53 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:3585 Date: 2003-12-19T14:13:53-08:00 List-Id: 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