gpt4 book ai didi

c++ - 交战 : Unused variable: rider ( Gmake, g++,freebsd)

转载 作者:太空宇宙 更新时间:2023-11-04 16:13:02 24 4
gpt4 key购买 nike

这是错误信息:

 File.cpp:130: warning: unused variable 'file'

代码如下:

我不想删除未使用的变量 rider。

想用不知道哪里错了

我的默认编译器是 GCC,在 freebsd 9.2 上

最佳答案

或者与其他答案一样,如果您坚持声明变量,您可以将其转换为 void 避免警告消息:

    LPCHARACTER rider = GetRider();
(void)rider; // Makes thé compiler look aside 'unused variable'
// ^^^^^^

如果您稍后决定使用该变量,上述语句不会造成任何伤害。

我发现这对于修复未使用的函数参数警告特别有用。

关于c++ - 交战 : Unused variable: rider ( Gmake, g++,freebsd),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26070882/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com