Re: [Linuxsampler-devel] Re: GCC Vector Extensions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 19, 2006 at 14:40:01 +0200, Christian Schoenebeck wrote:
> int main() {
>     const v4sf v = { 1.2f ,2.2f ,3.3f, 4.4f };
>     printf("v4sf v = { %f, %f, %f, %f }\n", ((float*)&v)[0],((float*)&v)[1],((float*)&v)[2],((float*)&v)[3]);
>     const v4i vRes = (v4i) v;
>     printf("v4i vRes = { %d, %d, %d, %d }\n", ((int*)&vRes)[0],((int*)&vRes)[1],((int*)&vRes)[2],((int*)&vRes)[3]);
> }

Shouldn't one use c++-style casts instead. static_cast<type>() is the 
one I think would be the one to use here. C-style casts are ambigous and 
most of the time its difficult or impossible to know what they should 
do.

This is the case because there is only one notation for all different 
type casts in C. In C++ you can use different type cast for different 
things.

See http://www.cplusplus.com/doc/tutorial/typecasting.html
for all 4 type casts in C++.

-Harri

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux