Re: schema pointer compatibility
"Prof A Olowofoyeku (The African Chief)" <[email protected]>
| Newsgroups | gmane.comp.compilers.gpc |
|---|---|
| Organization | ChiefSoft |
| Message-ID | <[email protected]> |
On 13 Aug 2012 at 10:46, Jay Michael wrote: > Why isn't the address of an object of a schema type an acceptable > value for a pointer to the (undiscriminated) schema type? > > type sptr_type = ^ string ; > type sptr_array_type( n : integer ) = array [ 1 .. n ] of sptr_type ; > type sptr_array_ptr_type = ^ sptr_array_type ; > > const s1 = 's1' ; > const s2 = 's2' ; > const s3 = 's3' ; > > const slist : sptr_array_type(3) = ( @s1, @s2, @s3 ) ; > > var slist_ptr : sptr_array_ptr_type = @slist ; > > > t12.pas:23: error: assignment from incompatible pointer type > > > I got the same error when I changed "slist" (the object of the > discriminated schema type) from a "const" to a "var". > I got the same error when I tried using an assignment statement: > > var slp : sptr_array_ptr_type ; > ... > slp := @slist ; > > If a discriminated instance of a schema type isn't quite the > same type as the undiscriminated type, then when would I ever be > able to use the address of an object as a value for a pointer to > the undiscriminated type? (without coercion, that is) Because what you are trying to do is rejected by the standards that you are implicitly following. Compile with "--no-typed-address", and it will compile. Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.greatchief.plus.com/ _______________________________________________ Gpc mailing list [email protected] https://www.g-n-u.de/mailman/listinfo/gpc