如下一段代码,用gcc和g++编译,gcc是ok的
g++提示 error: invalid type argument of unary ‘*’ (have ‘long int’)
error: expected primary-expression before ‘typeof’
g++增加编译选项-std=gnu++11 -std=c++11也不行
求问如何能编译通过呢?
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#define pal_rcu_assign_pointer(p, v) \
do { \
if(v!=NULL){(p) = (typeof(*v) *)(v);}else{(p)=NULL;} \
} while (0)
int main()
{
int * a=NULL;
printf("%p", a);
pal_rcu_assign_pointer(a, NULL);
printf("%p", a);
return 0;
}
#ifdef __cplusplus
}
#endif
--
FROM 36.112.24.*