I want to use typeof in clang but not __typeof__
. If I use typeof without declaring it I get warning the following warning
vector.c:14:5: warning: extension used [-Wlanguage-extension-token]
vec_init(&a,5);
^
./vector.h:27:26: note: expanded from macro 'vec_init'
((vec_ptr)->data) = (typeof((vec_ptr)->data)) malloc((capacity) * (sizeof((*((vec_ptr)->data))))) \
^
1 warning generated.
then I thought defining it might solve it so I added the following code:
#ifndef typeof
#ifdef __clang__
#define typeof(x) __typeof__(x)
#endif
#endif
With the added pre-processor definition I get the following error:
In file included from vector.c:1:
./vector.h:5:9: warning: keyword is hidden by macro definition [-Wkeyword-macro]
#define typeof(x) __typeof__(x)
^
1 warning generated.
but I get no error if I use __typeof__
instead.
How to solve this warning issue on clang?