Another pointer question

This is a discussion on Another pointer question within the vhdl forums in Programming Languages category; If I point to some basic type, how can I set the value at the pointer? eg: type I_ptr is access integer; .. .. .. variable A : I_ptr ... A := new integer; A := 10; --does not work - complains that A is not an integer (rightly so); same with any new types that are discrete type A_t; type A_ptr is access A_t; type A_t is (X, Y, Z); ... variable S : A_ptr; ... S := new A_t; S := X; --same problem as with integer; Am I, as usually, trying to go outside the scope of ...

Go Back   Application Development Forum > Programming Languages > vhdl

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-06-2008, 05:22 AM
Tricky
Guest
 
Default Another pointer question

If I point to some basic type, how can I set the value at the pointer?

eg:

type I_ptr is access integer;
..
..
..
variable A : I_ptr
...
A := new integer;

A := 10; --does not work - complains that A is not an integer (rightly
so);

same with any new types that are discrete

type A_t;
type A_ptr is access A_t;

type A_t is (X, Y, Z);
...
variable S : A_ptr;
...
S := new A_t;

S := X; --same problem as with integer;

Am I, as usually, trying to go outside the scope of VHDL?
Reply With Quote
  #2  
Old 08-06-2008, 07:32 AM
Brian Drummond
Guest
 
Default Re: Another pointer question

On Wed, 6 Aug 2008 02:22:29 -0700 (PDT), Tricky <Trickyhead@gmail.com>
wrote:

>If I point to some basic type, how can I set the value at the pointer?
>
>eg:


>type I_ptr is access integer;


>variable A : I_ptr
>..
>A := new integer;
>
>A := 10; --does not work - complains that A is not an integer (rightly
>so);


Dereferencing the pointer when you need the contents is normally
implicit; but in this case would cause ambiguity (to make it obvious,
consider a pointer to a pointer to an integer!).

However you can dereference it explicitly to avoid the problem

A.all := 10;

>S := new A_t;
>S := X; --same problem as with integer;


S.all := x;

- Brian

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 02:16 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.