草庐IT

fcatch-undefined-behavior

全部标签

c++ - 带 Eclipse CDT + MinGW + GLEW + GLFW 的 OpenGL : Undefined References

编辑:与此同时,我已经弄明白了这一点,并在下面写了一个详细的答案。我刚刚尝试在Win7上从MSVC10的Express版本切换到EclipseCDT,在配置时我遇到了以下简单OpenGL代码的问题(在VisualStudio中运行良好):#defineGLEW_STATIC#include#includeintmain(){GLFWwindow*w;if(!glfwInit())return-1;w=glfwCreateWindow(640,480,"HelloWorld",NULL,NULL);if(!w){glfwTerminate();return-1;}glfwMakeCont

c++ - G++ 与 Clang : inconsistent behavior for constexpr and const

考虑以下代码:constexprconstintA=42;constint&B=A;static_assert(&A==&B,"Bug");constexprconstint&C=B;static_assert(&A==&C,"Bug");intmain(){return0;}它被clang版本3.3完全接受,而g++(SUSELinux)4.8.120130909[gcc-4_8-branchrevision202388拒绝它:bug2.cpp:5:1:error:non-constantconditionforstaticassertionstatic_assert(&A==&B,

c++ - 对`i2c_smbus_read_word_data(int, unsigned char) 的 undefined reference

更新到Ubuntu18.04后,我无法编译我的Qt应用程序。出现以下错误:undefinedreferenceto`i2c_smbus_read_word_data(int,unsignedchar)据我了解,i2c_smbus_read_word_data现在不在linux/i2c-dev.h中定义,而是在动态库/usr/lib/x86_64-linux-gnu/libi2c.so中定义。我尝试动态链接:-li2c静态的:/usr/lib/x86_64-linux-gnu/libi2c.a但是还是有编译错误更新:已安装libi2c-dev、libi2c0和i2c-tools包。

c++ - 对类静态 constexpr 结构的 undefined reference ,g++ vs clang

这是我的代码,a.cp​​pstructint2{intx,y;};structFoo{staticconstexprintbar1=1;staticconstexprint2bar2={1,2};};intfoo1(){returnFoo::bar1;//thisisokforbothclang++andg++}int2foo2(){returnFoo::bar2;//undefinedreferenceto`Foo::bar2'inclang++}intmain(){std::cout使用clang编译,clang++-std=c++11a.cpp/tmp/a-0dba90.o:I

c++ - clang 的 -fcatch-undefined-behavior 没有像宣传的那样工作

我构建了llvm/compiler-rt/clang的3.1版本,我正在尝试查看-fcatch-undefined-behavior是否真的有任何作用。到目前为止,没有运气。例如。我编译运行#include#includeintmain(){int*x=malloc(sizeof(int)*10);printf("%d\n",x[20]);return0;}与$/usr/local/bin/clang-fcatch-undefined-behaviorundef_test.c&&./a.out0我是不是漏掉了一些非常简单的东西? 最佳答案

c++ - 体系结构 x86_64 链接 constexpr std::array 的 undefined symbol

我在链接目标文件时遇到错误:#include#includeenumSystemType:uint8_t{AC,DC,HCP,EFF};templatestructSystem;templatestructSystem{public:staticconstexprsize_tnumber_of_sockets=2;staticconstexprstd::arrayobject_per_socket{{12,6}};};我如下使用它来将数据分配到vector中。terminal->no_obj_per_system.assign(Sytem::object_per_socket.begi

c++ - SDL 导致 Undefined symbols : "_main", referenced from : start in crt1. 10.5.o

当我尝试在我的C++程序中使用SDL时,我得到以下信息:>g++minimal.cppSDLMain.mUndefinedsymbols:"_main",referencedfrom:startincrt1.10.5.old:symbol(s)notfoundcollect2:ldreturned1exitstatus这是我的minimal.cpp:#includeintmain(intargc,char**argv){return0;}我可以从http://www.libsdl.org/faq.php?action=listentries&category=7中收集到什么是通过包含S

c++ - 单例模式 : different behavior of auto_ptr and unique_ptr

在实现工厂类时,我遇到了一个我无法理解的std::auto_ptr行为。我将问题简化为以下小程序,所以...让我们开始吧。考虑以下单例类:单例.h#ifndefSINGLETON_H_#defineSINGLETON_H_#include#includeclasssingleton{public:staticsingleton*get(){std::coutptr_;//staticstd::unique_ptrptr_;};#endif单例.cpp#includeostd::auto_ptrsingleton::ptr_(0);//std::unique_ptrsingleton::

c++ - CUDA 6.0 链接错误 : undefined reference to `__cudaUnregisterFatBinary'

我正在尝试在Eclipse中编译一个简单的CUDA程序。g++-L/opt/cuda/lib64-o"cuda_esn"./cu_cuda_test.o./main.o-lcuda-lstdc++如您所见,我正在链接-lcuda并设置库路径-L/opt/cuda/lib64。但不幸的是,我不知道为什么这没有编译。完整输出:18:36:35****IncrementalBuildofconfigurationDefaultforprojectcuda_esn****makeallBuildingfile:../cuda_test.cuInvoking:CUDANVCCCompilernv

objective-c - 将 Zxing 包含到 Xcode 4.3 + Obj-C 时 undefined symbol

我在将ZXingWidget添加到我之前的iOS项目时遇到了一些问题。这是我之前使用XCode4.3+ARCforiOS开始的一个项目。对于这个项目,我需要包括ZXing来扫描。我遵循了提供的README。复制zxing到项目根目录,添加ZXingWidget.xcodeproj项目在构建阶段添加链接libZXingWidget.a将ZXingWidget添加到目标依赖项header搜索路径-递归$(SRCROOT)/zxing-read-only/iphone/ZXingWidget/Classesheader搜索路径-非递归$(SRCROOT)/zxing-read-only/cp