警告:赋值使指针从整数开始而不进行强制转换 [英] warning:assignment makes pointer from integer without a cast
问题描述
这是一个很常见的问题,但是我没有得到答案,所以再问一次.
Its quite a common question but I have not got my answer so asking it again.
我将构造函数定义为:
struct f_lock{
int x;
struct f_lock *next;
};
然后说我有一个功能:
struct f_lock *new_node()
{
struct f_lock *new_f_lock;
.....
return new_f_lock;
}
我从另一个函数调用:
struct f_lock *new_f_lock;
new_f_lock = new_node(); //This line gives the error warning:assignment makes pointer from integer without a cast
很乐意寻求帮助谢谢
推荐答案
您是否还收到错误的隐式声明函数"new_node"
?因为在这种情况下,您可能忘记了在调用它的模块中声明 new_node
.(如果没有收到该错误,请使用 -Wall
重新编译以打开更多警告.)
Did you also get the error implicit declaration of function ‘new_node’
? Because in that case, you probably forgot to declare new_node
in the module where you're calling it. (If you're not getting that error, recompile with -Wall
to turn more warnings on.)
警告消息的解释:如果未正确声明 new_node
,则编译器将假定它返回 int
,这是一种默认的返回类型(对于历史记录原因).
Explanation of the warning message: if new_node
has not been declared properly, the compiler will assume it returns int
, which is a kind of default return type (for historical reasons).
这篇关于警告:赋值使指针从整数开始而不进行强制转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!