#include <stdio.h>
#define ARRAY int, float
#define GET_1(_1) _1
#define GET_2(_1,...) GET_1(__VA_ARGS__)
#define GET_3(_1,...) GET_2(__VA_ARGS__)
#define GET_N2(_3,_2,_1,N,...) GET##N
#define GET_N(...) GET_N2(__VA_ARGS__,_3,_2,_1)
// GET idx argument from comma separated tokens
#define GET(array, idx) GET_N(array)(array)
int main() {
printf("%zu\n", sizeof(GET(ARRAY, 0)));
}
#include <stdio.h>
struct type_property {
size_t size;
};
#define TYPE_PROPERTY_INIT(type) { sizeof(type) }
struct type_property properties[] = {
TYPE_PROPERTY_INIT(int),
TYPE_PROPERTY_INIT(float),
};
int main() {
printf("%zu\n", properties[0].size);
}
#define variadic t_array = [ int, float ];
t_array[0]
#define swap(type, foo, bar) ({type tmp; tmp=foo; foo=bar; bar=tmp;})
#define tysize(type) tysize(({int a = sizeof(type); printf("%d", a);}))
int main()
{
tysize(int);
return 0;
}
({})работает только на gcc компиляторе, однако мой код не компилируется и выдается ошибка: