> I wrote the following test:
> 
> union foo { int i; double d; };
> 
> int main(int argc, char **argv)
> {
>      union foo f = { .d = 4 };
> 
>      ASSERT_EQ(0, f.i);
>      ASSERT_FEQ(4.0, f.d);
> 
>      return 0;
> }
> 
> ASSERT_EQ and ASSERT_FEQ are some macros which checks the falue and
> gives some error messages.
> 
> It seems that this extension should be bi-endian, however it fails on
> the sparc.
> What the problem with the test?

Type punning through union is actually the preferred way to expose endianness.
Ask yourself how the 'int' and the 'double' are laid out on the SPARC.

-- 
Eric Botcazou

Reply via email to