error: 'uint16_t' undeclared?

pandoragami picture pandoragami · Jul 2, 2013 · Viewed 58.7k times · Source

I have the code

#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;
}

and I'm getting an error where uint16_t isn't declared. I'm using GCC with MINGW.

Heres the complete error.

||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|

Answer

Carl Norum picture Carl Norum · Jul 3, 2013

You need to include stdint.h or inttypes.h to get uint16_t.