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.5 required=5.0 tests=BAYES_00,STOX_REPLY_TYPE autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,39c061fa6e3ec349 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news4.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!94.232.116.13.MISMATCH!feed.xsnews.nl!border-3.ams.xsnews.nl!upload-2.xsnews.nl!10.10.60.2.MISMATCH!frontend-F10-02.ams.news.kpn.nl From: "ldries46" Newsgroups: comp.lang.ada References: <4e2c416b$0$2574$703f8584@news.kpn.nl> In-Reply-To: Subject: Re: acceess problem Date: Mon, 25 Jul 2011 08:57:42 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 15.4.3508.1109 X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3508.1109 Message-ID: <4e2d13bc$0$2576$703f8584@news.kpn.nl> Organization: KPN.com NNTP-Posting-Host: 77.168.179.107 X-Trace: 1311577020 news.kpn.nl 2576 77.168.179.107@kpn/77.168.179.107:64999 Xref: g2news2.google.com comp.lang.ada:21311 Date: 2011-07-25T08:57:42+02:00 List-Id: I have done what you suggested and got the following error message on the line Axis1Amb : array (0 .. 3) of aliased GLfloat := (AxL, 0.0, 0.0, 1.0); non-local pointer cannot point to local object I agree that the bindings are not an example of beautifull ada programming but as far as I can see the biggest problem is that the OpenGL library is a rather old library with originally only C bindings. As you know C is not much more as a streamlined assembler language, where you do everything only for simplicity and no for readability. L. Dries "Simon Wright" schreef in bericht news:m2fwlvzj0a.fsf@pushface.org... "ldries46" writes: > I am converting a C/C++ program with openGL to Ada and found the > following problem: > > C/C++ code: float pAxis1Amb[] = { AxL, 0, 0, 1}; > glMaterialfv(vSide, GL_AMBIENT, pAxis1Amb); > where : GLAPI void APIENTRY glMaterialfv( GLenum face, GLenum > pname, const GLfloat *params ); > > In the Ada bindings the routine is declared as: > procedure glMaterialfv (face : GLenum; pname : > GLenum; params : GLfloatPtr); > where : type GLfloatPtr is access all GLfloat; > and : subtype GLfloat is Float; > I have created the following declarations : Axis1Amb : array(0..3) > of GLfloat := ( AxL, 0.0, 0.0, 1.0); > > pAxis1Amb > : GLfloatPtr := Axis1Amb'Access; > Now I get the following error message : prefix of "Access" attribute > must be aliased > I have to follow the C/C++ code as close as possible. > What do I do wrong? That managed to get formatted _really_ strangely! You could write Axis1Amb : array (0 .. 3) of aliased GLfloat := (AxL, 0.0, 0.0, 1.0); and then pAxis1Amb : GLfloatPtr := Axis1Amb (0)'Access; I guess you're going to pass pAxisAmb to glMaterialfv()? you will probably get away with this, since a pointer to the first element is very likely to be a pointer to the array. It might help to tie things down to add pragma Convention (C, Axis1Amb); I must say, this is a pretty low-quality binding! There appear to be 5 cases of 'pname' where 'params' is a 4-element array, one case where it's a 3-element array, and one where a single value is required. Actually IMO it's a low-quality C spec, too; a case of control coupling.