草庐IT

Function_Reference

全部标签

c++ - 链接器错误:对 `std::ctype<char>::_M_widen_init() 的 undefined reference

我在尝试运行示例项目时遇到链接器错误。你能告诉我如何解决这个问题吗?提前致谢。make[1]:Enteringdirectory`/home/rumi/MobiusProject/Multiproc-Paper/Transformer/ssg'/usr/bin/g++-w-DMOBIUS_LITTLE_ENDIAN-DMOBIUS_LINUX-m32-ossgGen_Linux-L../../lib/Linux_lib/-L/home/rumi/Mobius/mobius/Mobius-2.3/Cpp/lib/Linux_lib-L/home/rumi/Mobius/mobius/Mo

c++ - CPP : avoiding macro expansion of a macro function parameter

我想做的(为了记录目的)是这样的:编写这段代码是为了说明我的问题,实际代码很复杂,是的,即使在C++上我也有充分的理由使用宏=)#defineLIB_SOME1#defineLIB_OTHER2#defineWHERE"atfile#a,line#l,function#f:"//(lookforsyntaxhightlightingerroratSOxd)#defineLOG_ERROR_SIMPLE(ptr,lib,str)ptr->log("ERROR"str\"atlibrary"#lib);#defineLOG_ERROR(ptr,lib,str)LOG_ERROR_SIMPL

c++ - 错误 : use of deleted function ‘std::thread::thread(const std::thread&)'

下面的代码编译并按预期工作。结构(类)A派生自std::thread并扩展了一个int。main代码创建一些线程,然后等待它们完成。问题在于,虽然代码编译时没有结构A中的析构函数,但当析构函数未注释时(~A(){})我得到:error:useofdeletedfunction‘std::thread::thread(conststd::thread&)'我不知道为什么。此外,我不明白为什么代码既适用于push_back也适用于emplace_back而根据我的理解它不应该适用于push_back.#include#include#includestructA:std::thread{i

c++ - gcc 与 clang : inlining a function with -fPIC

考虑这段代码://foo.cxxintlast;intnext(){return++last;}intindex(intscale){returnnext()使用gcc7.2编译时:$g++-std=c++11-O3-fPIC这发出:next():movqlast@GOTPCREL(%rip),%rdxmovl(%rdx),%eaxaddl$1,%eaxmovl%eax,(%rdx)retindex(int):pushq%rbxmovl%edi,%ebxcallnext()@PLT##next()notinlined,callthroughPLTmovl%ebx,%ecxsall%cl

c++ - std::function 和 std::bind 做动态内存分配吗?

如果我这样做:-classThing{...voidfunction(conststd::string&message);};std::list>work;在“Thing”的一些成员中work.push_back(std::bind(&Thing::function,this,"Hello"));调用std::bind或使用std::function是否会导致使用new或其他方式进行任何动态内存分配?或者所有的存储空间都是在编译时分配的?如果标准没有说明任何内容,那么在visualstudio2012中呢,因为我的程序只需要在那里构建,为了提高效率,我可能需要在我考虑使用这种机制的地方

c++ - glfw3 编译 undefined reference

我在编译使用glfw3库的程序时遇到问题。尝试使用make进行编译时,我得到了undefinedreference的错误列表,但我的类被编译成.o文件,只有最终的可执行文件没有创建。标准输出:g++-Wall-g-cmain.cpp-lGL-lGLU-lglfw3-lX11-lXxf86vm-lXrandr-lpthread-lXig++-Wall-g-cerror.cpp-lGL-lGLU-lglfw3-lX11-lXxf86vm-lXrandr-lpthread-lXig++-Wall-g-csWindow.cpp-lGL-lGLU-lglfw3-lX11-lXxf86vm-lXr

c++11:如何编写包装函数来生成 `std::function` 对象

我正在尝试编写包装器make_function,就像std::make_pair可以创建一个std::function从合适的可调用对象中提取对象。就像make_pair,对于函数指针foo,autof0=make_function(foo);创建一个std::function函数对象f0正确的类型签名。只是为了澄清,我不介意偶尔给make_function类型参数如果很难(或不可能)完全从参数中推断出类型。到目前为止,我的想法(下面的代码)适用于lambda、一些函数指针和仿函数(我没有考虑volatiles)。但我无法让它为std::bind工作或std::bind结果。在下面的代

c++ - undefined reference ,在 64 位系统的 Ubuntu 上使用 FFMpeg-library (AvCodec)

我正在运行最新的FFMpeg库的示例代码。我已将示例代码插入到文件videofecencoder.c中:/**copyright(c)2001FabriceBellard**ThisfileispartofLibav.**Libavisfreesoftware;youcanredistributeitand/or*modifyitunderthetermsoftheGNULesserGeneralPublic*LicenseaspublishedbytheFreeSoftwareFoundation;either*version2.1oftheLicense,or(atyouropti

c++ - xcode 7 如何抑制警告 "overrides a member function but is not marked ' override'”

我今天将xcode更新为7。更新后,我正在处理的项目出现警告“覆盖成员函数但未标记为‘覆盖’”。由于我们的项目将“踩踏警告为错误”设置为true。我遇到了很多错误。我仔细检查了“OtherLinkerFlags”并且非常确定“-Wsuggest-override”标志不包括在内。因为这是一个大项目,我更喜欢抑制警告,而不是在任何地方添加关键字“override”。关于禁用警告的任何建议?谢谢 最佳答案 您需要关闭-Winconsistent-missing-override标志,该标志会在最新版本的clang上自动添加-Wall。您

c++ - 为什么C++中没有 "NULL reference"?

我正在阅读C++常见问题解答-“8.6-WhenshouldIusereferences,andwhenshouldIusepointers?”,尤其是以下声明:Usereferenceswhenyoucan,andpointerswhenyouhaveto....Theexceptiontotheaboveiswhereafunction'sparameterorreturnvalueneedsa"sentinel"reference—areferencethatdoesnotrefertoanobject.Thisisusuallybestdonebyreturning/takin