C 语言中基本数据类型的sizeof大小

时间:2021-09-18 17:26:02
#define SIZE_OF(TYPE)                                    \
  do {                                                   \
      printf ("sizeof ("#TYPE") = %d\n", sizeof (TYPE)); \
  } while (0);


int main (void)
{
#ifdef CPP
  SIZE_OF (bool); /* only defined in CPP */
#endif

  SIZE_OF (xtbool);
  SIZE_OF (xtbool4);
  SIZE_OF (xtbool8);

  SIZE_OF (char);
  SIZE_OF (short);
  SIZE_OF (int);
  SIZE_OF (long);
  SIZE_OF (long long);
  SIZE_OF (float);
  SIZE_OF (double);
  SIZE_OF (long double);
  
  /* Conditional Move related vectorMode.  */
  SIZE_OF (float16);
  SIZE_OF (float32);
  
  SIZE_OF (cfloat16);
  SIZE_OF (vfloat8x16);
  SIZE_OF (vfloat4x32);
  
  return 0;
}