代码是:
Push(size,(POINTER)(GetCar(i) == term_Null()? 0 : 1));
这是C代码推送返回ABC
typedef POINTER *ABC typedef void * POINTER ABC size; Push(ABC,POINTER); XYZ GetCar(int); typedef struct xyz *XYZ; XYZ term_Null(); long int i;
特定警告的原因是什么?
解决方法
您可以使用intptr_t来确保整数与指针的宽度相同.这样,您不需要发现有关您的特定平台的东西,它也可以在另一个平台上运行(与unsigned long解决方案不同).
#include <stdint.h> Push(size,(POINTER)(intptr_t)(GetCar(i) == term_Null()? 0 : 1));
取自C99标准:
7.18.1.4 Integer types capable of holding object pointers
1 The
following type designates a signed
integer type with the property that
any valid pointer to void can be
converted to this type,then converted
back to pointer to void,and the
result will compare equal to the
original pointer:intptr_t