This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

portability of __m128i static initializers between gcc and Microsoft C


I discovered an incompatability of the type definition of __m128i between gcc and Microsoft C that may cause a problem when moving source code between these two compilers when static initializers are used. Is there a process to address discrepancies of this nature?

What I wanted to do was create a value of type __m128i that had all one's.
const __m128i allOne =   ?

For gcc, a correct value is { -1, -1 }

It seems for Microsoft c, I'd need to provide a 16-element initializer. 
?
My takeaway is that portable code better avoid static initializers!

Type definitions follow:

# 39 "/usr/lib/gcc/x86_64-redhat-linux/4.3.2/include/emmintrin.h" 2 3 4
typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));

versus

#line 35 "c:\\program files\\microsoft visual studio 9.0\\vc\\include\\emmintrin.h"

typedef union __declspec(intrin_type) __declspec(align(16)) __m128i {
    __int8              m128i_i8[16];
    __int16             m128i_i16[8];
    __int32             m128i_i32[4];    
    __int64             m128i_i64[2];
    unsigned __int8     m128i_u8[16];
    unsigned __int16    m128i_u16[8];
    unsigned __int32    m128i_u32[4];
    unsigned __int64    m128i_u64[2];
} __m128i;

Regards,
Melanie Blower


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]