[sac-user] typedef more than just a synonym?

Scholz, Sven-Bodo S.Scholz at hw.ac.uk
Fri Feb 19 08:12:44 CET 2016


Yes. In contrast to C, a typedef in SaC introduces a new type! 
You have to explicitly convert from one type to another. 
Within the module that contains the typedef this can be done by using casts
(with the same syntax for casts as in C).

Bodo

> On 18 Feb 2016, at 22:27, Rob Stewart <R.Stewart at hw.ac.uk> wrote:
> 
> Hi,
> 
> This compiles:
> 
> int[.,.] transpose1(int[.,.] img)
> {
>  return ArrayTransform::transpose(img);
> }
> 
> 
> This doesn't compile:
> 
> typedef int[.,.] gray_image;
> gray_image transpose2(gray_image img )
> {
>  x = ArrayTransform::transpose((int[.,.]) img);
>  return ((gray_image) x);
> }
> 
> Is a typedef more than just a synonym?
> 
> Here's the error:
> 
>  **** Splitting Wrappers ...
> ./test.sac 8 error: All instances of "transpose2" contain type errors
> 
> error: line 11 in file ./test.sac
> error: inferred type _MAIN::gray_image[.,.] should match declared type _MAIN::gray_image
> 
> 
> Thanks,
> 
> --
> Rob
> _______________________________________________
> sac-user mailing list
> sac-user at sac-home.org
> http://lists.sac-home.org/mailman/listinfo/sac-user




More information about the sac-user mailing list