I am building some generic things in C.
Here is the code:
// main.c
#include <stdio.h>
#define T int;
#include "test.h"
int main()
{
    return 0;
}
// test.h
#define _array_is_pointer(T) (                \
    {                                         \
        T _value;                             \
        __builtin_classify_type(_value) == 5; \
    })
#ifdef T
#if _array_is_pointer(T)
struct array_s
{
    T *items;
}
void array_push(struct array_s * array, T value)
{
    // push method for pointer.
}
#else
struct array_s
{
    T *items;
}
void array_push(struct array_s * array, T value)
{
    // push method for non-pointer.
}
#endif
#endif
** edited: add more code in test.h **
I would like the preprocessor runs different code when T is pointer or non-pointer.
But I got an error token "{" is not valid in preprocessor expressions.
Is it possible to do that?
 
     
     
    