草庐IT

renewal-warning

全部标签

c++ - 是否存在 static_warning?

我知道thisquestion其中提到了Boost的“STATICWARNING”,但我想再问一次,具体来说,我如何实现一个static_warning,它的操作类似于static_assert但只发出一个在编译时发出警告,而不是中止编译错误。我想要类似于Alexandrescu在C++11之前提出的静态断言提案,它以某种方式设法打印一些有用的上下文信息作为错误的一部分。要求用户启用某些标准编译器警告以使此构造工作(可能是“无效指针转换”或“违反严格的别名规则”)是可以接受的——任何应该属于正常编译器的警告编译反正可以用。简而言之,我希望static_warning(false,"He

c++ - 友元函数默认模板 : Intel ICPC warning

我有以下测试代码://friendfunction.h#includetemplateclassMyClass{templatefriendinlineconstMyClassmyFunction(constT1&x,constMyClass&y);};template::value>::type>inlineconstMyClassmyFunction(constT0&x,constMyClass&y){std::cout(y);}//friendfunction.cpp#include"friendfunction.h"intmain(intargc,char*argv[]){My

c++ - VS2013 : How to disable warnings for included header files outside of the project

在我的项目中,我包含了一个由外部库提供的头文件。使用/W3,所有内容都可以在没有警告的情况下编译。但是,我希望我的项目能够使用/W4进行干净地编译。这对我的代码来说没有问题,但外部header会发出大量警告。我知道我可以做这样的事情:#pragmawarning(push)#pragmawarning(disable:####)//includehere#pragmawarning(pop)但是有一长串要禁用的警告。有没有一种方法可以在包含此header时将警告级别设置回/W3,同时仍使用/W4编译我的其余代码?谢谢! 最佳答案 #

CMake Warning (dev) at cmake/OpenCVDetectPython.cmake:140 (find_package): Policy CMP0148 is not set

1、原文在opencv编译的时候CMakeWarning(dev)atcmake/OpenCVUtils.cmake:144(find_package):PolicyCMP0148isnotset:TheFindPythonInterpandFindPythonLibsmodulesareremoved.Run"cmake--help-policyCMP0148"forpolicydetails.Usethecmake_policycommandtosetthepolicyandsuppressthiswarning.`CallStack(mostrecentcallfirst):cmake/

c++ - 提神气 : How to report parser warnings?

如何报告解析器警告?类似于报告错误,但解析器不能停止。仅记录警告消息和引起警告的子表达式。示例输入:select*fromtablewhererow>=''&&row'hello'预期输出:Warning:expressionisalwaystrue:row>=''Warning:&&isdeprecated,useAND:row>=''&&row'hello'Warning:isdeprecated,use!=:row'hello' 最佳答案 如果你想继续解析你可以像以前一样注册一个错误处理程序,除了你必须指定accept作为处理

c++ - VS2008 : Disable warnings in included header files outside the project

这可能吗?我不想全局禁用警告,因为我想检查我自己的头文件是否有警告。 最佳答案 您可以禁用有关包含外部头文件的警告:#pragmawarning(push)#pragmawarning(disable:thewarning)//includehere#pragmawarning(pop)如果您需要多次包含标题,您可以使用编译指示创建一个标题并将其包含在内。问了同样的问题here. 关于c++-VS2008:Disablewarningsinincludedheaderfilesoutsi

c++ - "warning C4800: ' int' : forcing value to bool 'true' or 'false' "不同场景下的不同行为

我无法理解此警告的以下行为。case1:boolread=(33&3);//NoWarningissuedbyvs2013case2:intb=33;boolread=(b&3);//NowcompilerisgeneratingC4800warning.为什么编译器在情况2中生成警告,而在情况1中不发出任何警告。 最佳答案 C4800是一个性能警告-在运行时将整数强制转换为bool会产生成本。这与逻辑正确性无关。最常见的强制转换(和警告)发生在您与使用整数(VC++中的BOOL)作为bool值的代码交互时。第一个代码段中的编译时强

c++ - 用C++17编译Eigen需要_SILENCE_CXX17_NEGATORS_DEPRECATION_WARNING定义

我正在尝试分配一个稀疏矩阵block,但无法让它工作。似乎eigen使用的函数已被弃用,我可以用一些定义来修复它。但是,我确定我是应该将这些定义添加到项目中还是等待更新版本的Eigen。你们能否就定义的副作用提出建议。我写的程序是这样的#includeintmain(){Eigen::SparseMatrixm(4,4);m.block(0,0,2,2)这是警告:1>d:\eigen_3.3.4\eigen\src\core\functors\stlfunctors.h(87):errorC4996:'std::unary_negate':warningSTL4008:std::not

c++ - %llx 格式说明符 : invalid warning?

已编辑以删除第一个警告以下代码在mingw32下的g++4.4.0中按预期工作:#includeintmain(){longlongx=0xdeadbeefc0defaceLL;printf("%llx\n",x);}但是如果我使用-Wall启用所有警告,它会说:f.cpp:Infunction'intmain()':f.cpp:5:warning:unknownconversiontypecharacter'l'informatf.cpp:5:warning:toomanyargumentsforformat%lld也是一样。这在较新的版本中已修复吗?再次编辑添加:如果我指定-std

c++ - 杂乱的函数指针 : how to remove the warning?

正如我在thispost中提问和回答的那样.我有以下示例代码。#includecharfoo(){return'a';}charbar(){return'b';}charblurga(){return'c';}charbletch(){return'd';}char(*gfunclist[])()={foo,bar,blurga,bletch};char(*(*x())[])(){staticchar(*funclist[4])()={foo,bar,blurga,bletch};returnfunclist;}intmain(){printf("%c\n",gfunclist[0](