none
error C2719: 'a': formal parameter with __declspec(align('16')) won't be aligned

    Question

  • I try to use the mmx to implement the sse2 intrinsics functions because my code has a heavy call to them while I must make it run on old cpu.

    typedef __declspec(align(16)) struct {
        __m64 v64[2];
    } ___m128i;

    #define __m128i ___m128i

    __inline __m128i
    dcm_add_epi8(__m128i a, __m128i b)
    {
        __m128i x;
        x.v64[0] = _mm_add_pi8(a.v64[0], b.v64[0]);
        x.v64[1] = _mm_add_pi8(a.v64[1], b.v64[1]);
        return x;
    }

    but when I compile the code, the vc2008 compiler reports:

    error C2719: 'a': formal parameter with __declspec(align('16')) won't be aligned

    error C2719: 'b': formal parameter with __declspec(align('16')) won't be aligned

    Monday, April 05, 2010 5:57 PM

Answers

  • Hello hurric,

    Error C2719 specifies that 'The align __declspec modifier is not permitted on function parameters'. [http://msdn.microsoft.com/en-us/library/373ak2y1(VS.71).aspx]

    Hence instead of passing the parameters as objects, you can pass them as pointers to objects.

    i.e.

    typedef __declspec(align(16)) struct {
        __m64 v64[2];
    } ___m128i;
    
    #define __m128i ___m128i
    
    __inline __m128i
    dcm_add_epi8(__m128i* a, __m128i* b) 
    {
        __m128i x;
        x.v64[0] = _mm_add_pi8(a->v64[0], b->v64[0]);
        x.v64[1] = _mm_add_pi8(a->v64[1], b->v64[1]);
        return x;
    }

     

    Hope this helps

    • Marked as answer by Nancy Shao Tuesday, April 13, 2010 5:53 AM
    Tuesday, April 06, 2010 7:21 AM