草庐IT

warn_unused_result

全部标签

c++ - 使用 'g++' 结果为 "warning: will never be executed"

我继承了一个C++项目。我在RHELbuild5.5与GCC4.1.2通过makefile。该项目很大(数百个文件),总的来说代码还不错。然而,在编译过程中,我经常收到一个GCC警告,上面写着(prefix"/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2"):/bits/allocator.h:Inconstructor‘std::allocator::allocator()[with_Tp=char]’:/bits/allocator.h:97:warning:willneverbeexecuted

c++ - 为什么编译器在我定义了 _CRT_SECURE_NO_WARNINGS 之后仍然警告我不安全的 strtok?

我正在使用适用于Windows桌面的VisualStudioExpress2012。我总是出错ErrorC4996:'strtok':Thisfunctionorvariablemaybeunsafe.Considerusingstrtok_sinstead.Todisabledeprecation,use_CRT_SECURE_NO_WARNINGS.Seeonlinehelpfordetails.当我尝试构建以下内容时:#include"stdafx.h"#define_CRT_SECURE_NO_WARNINGS#include#includeusingnamespacestd;

c++ - GCC 选项 : warning on non-void functions without a return statement

如果存在具有非空返回值但在其定义中不包含return语句的函数,是否有生成错误/警告的GCC/g++选项?例如:intadd(inta,intb){a+b;} 最佳答案 -Wreturn-type.它由-Wall(您应该始终与-Werror-Wextra一起运行)启用。 关于c++-GCC选项:warningonnon-voidfunctionswithoutareturnstatement,我们在StackOverflow上找到一个类似的问题: https:

c++ - g++ 表示 : warning: statement has no effect for shift bits operators

我正在实现alkhwarizmi算法。没错,但我的g++编译器不喜欢移位运算符:>>和当我编译它时,我得到这个输出:>g++-Wall-std=c++0x-o"Al-khwarizmialgorithm.o""Al-khwarizmialgorithm.cpp"(indirectory:/home/akronix/workspace/Algorithms)>Al-khwarizmialgorithm.cpp:Infunction‘intalkhwarizmi(int,int)’:Al-khwarizmialgorithm.cpp:31:9:warning:statementhasnoe

PHP致命错误:致电未定义功能mysqli_stmt_get_result()

我一直在遇到错误php致命错误:调用未定义的功能mysqli_stmt_get_result()。我正在使用PHP版本5.6,并启用了托管提供商C面板中的扩展MySqlind,但我无法弄清楚为什么我仍然会遇到此错误。我已经研究并发现每次需要Mysqlind都可以使用mysqli_stmt_get_result。任何人都可以协助/教我做错了什么。谢谢你。Ingip.php:true,'message'=>'Therewasanerror','redirect','errors');if(isset($_POST['submit'])){$first=$_POST['first'];$last=$

c++ - 新手在这里 : Different results on PC and MAC. 为什么?

这个问题在这里已经有了答案:Whyaretheseconstructsusingpreandpost-incrementundefinedbehavior?(14个答案)关闭8年前。我现在正在尝试学习C/C++的基础知识。我正在学习Lynda.com上的类(class)我的问题涉及第4章“C/C++基本培训类(class)中的宏警告”中的一系列代码。我已按照所有设置程序在Mac上正确设置Xcode和Eclipse,在PC上正确设置Eclipse。当我在MAC和PC上运行这段代码时,我得到了不同的结果。只是想了解为什么会发生这种情况,以及我可以做些什么来在两者上获得相同的结果。代码如下:

c++ - 未解析的外部符号 "private: static int Math::result"

这个问题在这里已经有了答案:Whatisanundefinedreference/unresolvedexternalsymbolerrorandhowdoIfixit?(38个答案)关闭8年前。这是我的类定义:#includeusingnamespacestd;classMath{private:staticintresult;public:staticintadd(inta,intb){result=a+b;returnresult;};};这是主要的:#include#include"Amin.cpp"usingnamespacestd;intmain(){Math::add(2

python - C++ python API : second call of PyImport_Import results in SIGSEGV

我正在尝试通过cApi从c++调用python,以获取c++中两个numpy数组的值。第一次调用我的程序callPython()时,一切似乎都运行良好,但第二次调用导致SIGSEGV时pModule=PyImport_Import(pName);被执行。在flebool的回答中,有一个比我的简单得多的最小示例代码,但有同样的错误。最小.cpp#include#includelongintgeTuple(PyObject*pValue,PyObject*objI,inti){objI=PyTuple_GetItem(pValue,i);longintn,M;double*xJ;if(ob

c++ - 对齐 : warning C4316 in all classes that have aligned members

今天我遇到了很多麻烦,因为我跟踪了一个非常隐蔽的腐败漏洞。我想如果我真的注意警告就不会那么难找到它,但由于找不到有关为什么弹出此特定警告的相关信息,我让它滑动了,这是一个错误。所以这是VisualStudio2013给我的有罪警告:warningC4316:objectallocatedontheheapmaynotbealigned16它是在通过const引用将align(16)临时传递给构造函数时生成的,如以下代码所示:classVector{};__declspec(align(16))classVectorA{};classShape{public:Shape(constVec

c++ - 为什么没有为所有变量报告 "unused variable"警告?

这个问题在这里已经有了答案:g++doesnotshowa'unused'warning(3个答案)关闭8年前。我有这个代码://initializerlists#include#includeintmain(){intvalues[]{1,2,3};std::vectorv{4,5,6};std::vectorcities{"London","NewYork","Paris","Tokio"};return0;}然而,gcc编译器只针对values数组给我unusedvariable警告。为什么v和cities没有被报告?