奇怪的警告gcc
有人可以解释这个警告消息吗?
rx@bet~/Scrivania/rx_fine$:gcc -c -Wall proxy_invio.c
proxy_invio.c: In function ‘main’:
proxy_invio.c:1028:26: warning: variable ‘len2’ set but not used [-Wunused-but-set-variable]
这是 proxy_invio.c 文件的内容:
#define GETMHTTP "GET mhttp://"
main(){
int len2;
//blablabla
len2=strlen(GETMHTTP);
//blablabla
}
@编辑:这只是由于复制粘贴误用而产生的错误。我并不是愚蠢到不明白警告信息的含义,而是愚蠢到没有看到未来。
Can someone explain this warning message ?
rx@bet~/Scrivania/rx_fine$:gcc -c -Wall proxy_invio.c
proxy_invio.c: In function ‘main’:
proxy_invio.c:1028:26: warning: variable ‘len2’ set but not used [-Wunused-but-set-variable]
This is the content of the proxy_invio.c file :
#define GETMHTTP "GET mhttp://"
main(){
int len2;
//blablabla
len2=strlen(GETMHTTP);
//blablabla
}
@EDIT: it was just an error created by a copy-paste misused. I was not so stupid to not understand the meaning of the warning message, but so stupid to not see forward.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您已经设置了该变量,但后来从未使用过它(在
len2=strlen(GETMHTTP);
之后)。You have set the variable, but you never used it later (after
len2=strlen(GETMHTTP);
).这非常简单:您将变量设置为某个值,但之后就不再使用它。
我认为可以肯定地说,您可以简单地从代码中删除这两个语句。或者您可能计划在某个地方使用 len2 ,但您忘记了。
It's pretty simple : you set the variable to some value, but you never use it afterward.
I thinks it's pretty safe to say that you can simply delete these two statements from your code. Or maybe you were planing on using
len2
somewhere but you forgot.