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 autolearn=ham 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!news3.google.com!proxad.net!feeder1-2.proxad.net!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: acceess problem Date: Sun, 24 Jul 2011 18:27:33 +0100 Organization: A noiseless patient Spider Message-ID: References: <4e2c416b$0$2574$703f8584@news.kpn.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="2452"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dr2/5yZ5qmql0Ym2tEjMIkU7heV6+hU0=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:AwH2DLh++njlQRhIA0ba4nNGyfE= sha1:PiTfLoNhfF+EEirB4oJENqzZdhk= Xref: g2news2.google.com comp.lang.ada:21306 Date: 2011-07-24T18:27:33+01:00 List-Id: "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.