我试图移植到 64 位的 C 源代码在 32 位环境中运行时没有任何警告。当我使用 compile gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1 在 64 位 Linux 环境中编译时,它主要显示以下警告:
warning: cast to pointer from integer of different size
上面的警告是最多的。我使用了uintptr_t类型,大部分警告都被删除了。我可以使用uintptr_t将类型int /unsigned int更改为 有利的 64 位。但是如何更改以下类型以兼容 64 位:
typedef void* POINTER;
我更改了以下代码:
typedef unsigned int ABC;
进入
typedef uintptr_t ABC
我收到以下警告:
warning: passing argument 2 of ‘function’ from incompatible pointer type
note: expected ‘ABC *’ but argument is of type ‘unsigned int *’
此外,在将类型 def 更改为早期的 int 或 unsigned int 的 uintptr_t 后,我遇到了以下大部分警告:
warning: inlining failed in call to ‘abc_StringCopy’: call is unlikely and code size would grow
函数 tptp_StringCopy 如下:
static __inline__ char* abc_StringCopy(void)
{
char *copy;
copy = (char*)Malloc(yyleng+1);
strcpy(copy, yytext);
return copy;
我怎样才能摆脱这些警告?