31

我有代码

#include <emmintrin.h>
#include <stdio.h>

void print128_num(__m128i var)
{
    uint16_t *val = (uint16_t*) &var;
    printf("Numerical: %i %i %i %i %i %i %i %i \n",
           val[0], val[1], val[2], val[3], val[4], val[5],
           val[6], val[7]);
}
int main(void)
{
    __m128i a = _mm_set_epi32(4, 3, 2, 1);
    __m128i b = _mm_set_epi32(7, 6, 5, 4);
    __m128i c = _mm_add_epi32(a, b);

    print128_num(c);

    return 0;
}

我在uint16_t未声明的地方遇到错误。我将 GCC 与 MINGW 一起使用。

这是完整的错误。

||In function 'print128_num':|
|6|error: 'uint16_t' undeclared (first use in this function)|
|6|error: (Each undeclared identifier is reported only once|
|6|error: for each function it appears in.)|
|6|error: 'val' undeclared (first use in this function)|
|6|error: expected expression before ')' token|
4

1 回答 1

75

您需要包含stdint.hinttypes.h获取uint16_t.

于 2013-07-02T22:00:20.727 回答