comp.lang.ada
 help / color / mirror / Atom feed
* Re: Problems with GLUT on NT and "deeper accessibility"
  1998-10-30  0:00 Problems with GLUT on NT and "deeper accessibility" Rolf Wester
  1998-10-30  0:00 ` David C. Hoos, Sr.
@ 1998-10-30  0:00 ` Matthew Heaney
  1998-10-30  0:00   ` Rolf Wester
  1 sibling, 1 reply; 5+ messages in thread
From: Matthew Heaney @ 1998-10-30  0:00 UTC (permalink / raw)


Rolf Wester <WESTER@ilt.fhg.de> writes:

Use T'Unchecked_Access.




> Hi,
> 
> I installed GNAT, AdaWin32 and  GLUT according to the instructions on
> "Jerry's Ada on Win32 Page". I also downloaded the GLUT sources. When I
> try to compile the program ada_sphere_procs.adb (with win32.gl,
> win32.glu) I get the following error message:
> 
> Compiling...
> ada_sphere_procs.adb:41:38: object has deeper accessibility level than
> access type
> ada_sphere_procs.adb:42:39: object has deeper accessibility level than
> access type
> 
> The code fragment is:
>       procedure init is
> 
>        light_diffuse : array(0 .. 3) of aliased GLfloat :=
>                     (1.0, 0.0, 0.0, 1.0);
>        light_position : array(0 .. 3) of aliased GLfloat :=
>                     (1.0, 1.0, 1.0, 0.0);
> 
>        begin
>        glClearColor(0.1, 0.1, 0.1, 0.0);
> 
>        glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse(0)'access); --
> line 41
>        glLightfv(GL_LIGHT0, GL_POSITION, light_position(0)'access); --
> line 42
> 
> The function glLightfv is defined in win32-gl.ads as:
>        procedure glLightfv(
>                 light : GLenum;
>                 pname : GLenum;
>                 params: ac_GLfloat);
> 
> and ac_GLfloat is  defined as:
>        type GLfloat is new Win32.FLOAT;
>        type ac_GLfloat is access constant GLfloat;
> 
> When I change the code to:
> 
>      procedure init is
> 
>         light_diffuse : array(0 .. 3) of aliased GLfloat :=
>                (1.0, 0.0, 0.0, 1.0);
>         light_position : array(0 .. 3) of aliased GLfloat :=
>                (1.0, 1.0, 1.0, 0.0);
>          type my_ac_GLfloat is access constant GLfloat;
>          myFA : my_ac_GLfloat;
>          FA   : ac_GLfloat;
>   begin
>         glClearColor(0.1, 0.1, 0.1, 0.0);
> 
>          myFA := light_diffuse(0)'access;  --line 43
>          FA   := light_diffuse(0)'access;    -- line 44
> 
>          glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse(0)'access);
> --line 46
>          glLightfv(GL_LIGHT0, GL_POSITION, light_position(0)'access); --
> line 47
> 
> I get the following error messages:
> 
> Compiling...
> ada_sphere_procs.adb:44:13: object has deeper accessibility level than
> access type
> ada_sphere_procs.adb:46:38: object has deeper accessibility level than
> access type
> ada_sphere_procs.adb:47:39: object has deeper accessibility level than
> access type
> 
> With my own my_ac_GLfloat on line 43 it's O.K. with the win32.gl
> ac_GLfloat
> used on line 44 it's an error!
> 
> I would be very appreciative for any help.
> 
> Thanks in anticipation
> 
> - Rolf
> 
> P.S.: Could anybody explain me the difference between
>        type ac_GLfloat is access constant GLfloat;
> and
>        type ac_GLfloat is access all GLfloat;
> 
> 
> ----------------------------------------------------------------------------
> 
> Rolf Wester
> Fraunhofer-Institute for Laser Technology
> Aachen
> Germany
> wester@ilt.fhg.de




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

* Re: Problems with GLUT on NT and "deeper accessibility"
  1998-10-30  0:00 ` Matthew Heaney
@ 1998-10-30  0:00   ` Rolf Wester
  1998-10-30  0:00     ` Robert A Duff
  0 siblings, 1 reply; 5+ messages in thread
From: Rolf Wester @ 1998-10-30  0:00 UTC (permalink / raw)


Thanks for the answer.

Could you or anyone else tell an Ada novice why the program does'nt work with
"access" but with "Unchecked_Access"? When I define my own "my_ac_GLfloat" in the
same way  "ac_GLfloat"  is defined in win32.gl it works with "access".



Matthew Heaney wrote:

> Rolf Wester <WESTER@ilt.fhg.de> writes:
>
> Use T'Unchecked_Access.
>
> > Hi,
> >
> > I installed GNAT, AdaWin32 and  GLUT according to the instructions on
> > "Jerry's Ada on Win32 Page". I also downloaded the GLUT sources. When I
> > try to compile the program ada_sphere_procs.adb (with win32.gl,
> > win32.glu) I get the following error message:
> >
> > Compiling...
> > ada_sphere_procs.adb:41:38: object has deeper accessibility level than
> > access type
> > ada_sphere_procs.adb:42:39: object has deeper accessibility level than
> > access type
> >
> > The code fragment is:
> >       procedure init is
> >
> >        light_diffuse : array(0 .. 3) of aliased GLfloat :=
> >                     (1.0, 0.0, 0.0, 1.0);
> >        light_position : array(0 .. 3) of aliased GLfloat :=
> >                     (1.0, 1.0, 1.0, 0.0);
> >
> >        begin
> >        glClearColor(0.1, 0.1, 0.1, 0.0);
> >
> >        glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse(0)'access); --
> > line 41
> >        glLightfv(GL_LIGHT0, GL_POSITION, light_position(0)'access); --
> > line 42
> >
> > The function glLightfv is defined in win32-gl.ads as:
> >        procedure glLightfv(
> >                 light : GLenum;
> >                 pname : GLenum;
> >                 params: ac_GLfloat);
> >
> > and ac_GLfloat is  defined as:
> >        type GLfloat is new Win32.FLOAT;
> >        type ac_GLfloat is access constant GLfloat;
> >
> > When I change the code to:
> >
> >      procedure init is
> >
> >         light_diffuse : array(0 .. 3) of aliased GLfloat :=
> >                (1.0, 0.0, 0.0, 1.0);
> >         light_position : array(0 .. 3) of aliased GLfloat :=
> >                (1.0, 1.0, 1.0, 0.0);
> >          type my_ac_GLfloat is access constant GLfloat;
> >          myFA : my_ac_GLfloat;
> >          FA   : ac_GLfloat;
> >   begin
> >         glClearColor(0.1, 0.1, 0.1, 0.0);
> >
> >          myFA := light_diffuse(0)'access;  --line 43
> >          FA   := light_diffuse(0)'access;    -- line 44
> >
> >          glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse(0)'access);
> > --line 46
> >          glLightfv(GL_LIGHT0, GL_POSITION, light_position(0)'access); --
> > line 47
> >
> > I get the following error messages:
> >
> > Compiling...
> > ada_sphere_procs.adb:44:13: object has deeper accessibility level than
> > access type
> > ada_sphere_procs.adb:46:38: object has deeper accessibility level than
> > access type
> > ada_sphere_procs.adb:47:39: object has deeper accessibility level than
> > access type
> >
> > With my own my_ac_GLfloat on line 43 it's O.K. with the win32.gl
> > ac_GLfloat
> > used on line 44 it's an error!
> >
> > I would be very appreciative for any help.
> >
> > Thanks in anticipation
> >
> > - Rolf
> >
> > P.S.: Could anybody explain me the difference between
> >        type ac_GLfloat is access constant GLfloat;
> > and
> >        type ac_GLfloat is access all GLfloat;
> >
> >
> > ----------------------------------------------------------------------------
> >
> > Rolf Wester
> > Fraunhofer-Institute for Laser Technology
> > Aachen
> > Germany
> > wester@ilt.fhg.de



--
------------------------------------------------------------
# Rolf Wester
# Fraunhofer Institut f. Lasertechnik
# Steinbachstr. 15, D-52074 Aachen, Germany.
# Tel: + 49 (0) 241 8906 0, Fax: +49 (0) 241 8906 121
# EMail: wester@ilt.fhg.de, WWW: http://www.ilt.fhg.de






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

* Re: Problems with GLUT on NT and "deeper accessibility"
  1998-10-30  0:00   ` Rolf Wester
@ 1998-10-30  0:00     ` Robert A Duff
  0 siblings, 0 replies; 5+ messages in thread
From: Robert A Duff @ 1998-10-30  0:00 UTC (permalink / raw)


Rolf Wester <WESTER@ilt.fhg.de> writes:

> Could you or anyone else tell an Ada novice why the program does'nt work with
> "access" but with "Unchecked_Access"? When I define my own "my_ac_GLfloat" in the
> same way  "ac_GLfloat"  is defined in win32.gl it works with "access".

The accessibility rules are intended to prevent dangling pointers,
unless you use one of the Unchecked_... features.  Mostly, these rules
are checked at compile time, which means they are necessarily
conservative.

You were able to create a pointer of type my_ac_GLfloat using 'Access
because that access type is nested inside the procedure -- it has the
same lifetime as the object, so it's impossible to assign those pointers
into globals.  The type ac_GLfloat, OTOH, is more global -- if you could
use 'Access to make a pointer of type ac_GLfloat pointing to a local,
then when the procedure returns, that pointer could remain -- it's a
dangling pointer.

Note that if you tried to do a type conversion from my_ac_GLfloat to
ac_GLfloat, you would get the same error, for the same reason.

Does glLightfv save that pointer?  If so, you had better not use
'Unchecked_Access -- you better move your data to a global place, or put
it on the heap.  It not, you can use 'Unchecked_Access.

- Bob
-- 
Change robert to bob to get my real email address.  Sorry.




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

* Re: Problems with GLUT on NT and "deeper accessibility"
  1998-10-30  0:00 Problems with GLUT on NT and "deeper accessibility" Rolf Wester
@ 1998-10-30  0:00 ` David C. Hoos, Sr.
  1998-10-30  0:00 ` Matthew Heaney
  1 sibling, 0 replies; 5+ messages in thread
From: David C. Hoos, Sr. @ 1998-10-30  0:00 UTC (permalink / raw)



Rolf Wester wrote in message <3639682C.AA824493@ilt.fhg.de>...

<snip>

>P.S.: Could anybody explain me the difference between
>       type ac_GLfloat is access constant GLfloat;
>and
>       type ac_GLfloat is access all GLfloat;

Perhaps a small excerpt from the Ada95 Langage Reference Manual section 3.10
(Access Types) will suffice:
(Note especially 3.10 (10)

8 Access-to-object types are further subdivided into pool-specific access
types, whose values can designate only the elements
of their associated storage pool, and general access types, whose values can
designate the elements of any storage pool, as
well as aliased objects created by declarations rather than allocators, and
aliased subcomponents of other objects.

9 A view of an object is defined to be aliased if it is defined by an
object_declaration or component_definition with the
reserved word aliased, or by a renaming of an aliased view. In addition, the
dereference of an access-to-object value denotes
an aliased view, as does a view conversion (see 4.6) of an aliased view.
Finally, the current instance of a limited type, and
a formal parameter or generic formal object of a tagged type are defined to
be aliased. Aliased views are the ones that can
be designated by an access value. If the view defined by an
object_declaration is aliased, and the type of the object has
discriminants, then the object is constrained; if its nominal subtype is
unconstrained, then the object is constrained by its
initial value. Similarly, if the object created by an allocator has
discriminants, the object is constrained, either by the
designated subtype, or by its initial value.

10 An access_to_object_definition defines an access-to-object type and its
first subtype; the subtype_indication defines the
designated subtype of the access type. If a general_access_modifier appears,
then the access type is a general access type.
If the modifier is the reserved word constant, then the type is an
access-to-constant type; a designated object cannot be
updated through a value of such a type. If the modifier is the reserved word
all, then the type is an access-to-variable
type; a designated object can be both read and updated through a value of
such a type. If no general_access_modifier appears
in the access_to_object_definition, the access type is a pool-specific
access-to-variable type.








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

* Problems with GLUT on NT and "deeper accessibility"
@ 1998-10-30  0:00 Rolf Wester
  1998-10-30  0:00 ` David C. Hoos, Sr.
  1998-10-30  0:00 ` Matthew Heaney
  0 siblings, 2 replies; 5+ messages in thread
From: Rolf Wester @ 1998-10-30  0:00 UTC (permalink / raw)


Hi,

I installed GNAT, AdaWin32 and  GLUT according to the instructions on
"Jerry's Ada on Win32 Page". I also downloaded the GLUT sources. When I
try to compile the program ada_sphere_procs.adb (with win32.gl,
win32.glu) I get the following error message:

Compiling...
ada_sphere_procs.adb:41:38: object has deeper accessibility level than
access type
ada_sphere_procs.adb:42:39: object has deeper accessibility level than
access type

The code fragment is:
      procedure init is

       light_diffuse : array(0 .. 3) of aliased GLfloat :=
                    (1.0, 0.0, 0.0, 1.0);
       light_position : array(0 .. 3) of aliased GLfloat :=
                    (1.0, 1.0, 1.0, 0.0);

       begin
       glClearColor(0.1, 0.1, 0.1, 0.0);

       glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse(0)'access); --
line 41
       glLightfv(GL_LIGHT0, GL_POSITION, light_position(0)'access); --
line 42

The function glLightfv is defined in win32-gl.ads as:
       procedure glLightfv(
                light : GLenum;
                pname : GLenum;
                params: ac_GLfloat);

and ac_GLfloat is  defined as:
       type GLfloat is new Win32.FLOAT;
       type ac_GLfloat is access constant GLfloat;

When I change the code to:

     procedure init is

        light_diffuse : array(0 .. 3) of aliased GLfloat :=
               (1.0, 0.0, 0.0, 1.0);
        light_position : array(0 .. 3) of aliased GLfloat :=
               (1.0, 1.0, 1.0, 0.0);
         type my_ac_GLfloat is access constant GLfloat;
         myFA : my_ac_GLfloat;
         FA   : ac_GLfloat;
  begin
        glClearColor(0.1, 0.1, 0.1, 0.0);

         myFA := light_diffuse(0)'access;  --line 43
         FA   := light_diffuse(0)'access;    -- line 44

         glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse(0)'access);
--line 46
         glLightfv(GL_LIGHT0, GL_POSITION, light_position(0)'access); --
line 47

I get the following error messages:

Compiling...
ada_sphere_procs.adb:44:13: object has deeper accessibility level than
access type
ada_sphere_procs.adb:46:38: object has deeper accessibility level than
access type
ada_sphere_procs.adb:47:39: object has deeper accessibility level than
access type

With my own my_ac_GLfloat on line 43 it's O.K. with the win32.gl
ac_GLfloat
used on line 44 it's an error!

I would be very appreciative for any help.

Thanks in anticipation

- Rolf

P.S.: Could anybody explain me the difference between
       type ac_GLfloat is access constant GLfloat;
and
       type ac_GLfloat is access all GLfloat;


----------------------------------------------------------------------------

Rolf Wester
Fraunhofer-Institute for Laser Technology
Aachen
Germany
wester@ilt.fhg.de







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

end of thread, other threads:[~1998-10-30  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-30  0:00 Problems with GLUT on NT and "deeper accessibility" Rolf Wester
1998-10-30  0:00 ` David C. Hoos, Sr.
1998-10-30  0:00 ` Matthew Heaney
1998-10-30  0:00   ` Rolf Wester
1998-10-30  0:00     ` Robert A Duff

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