understanding-weak-references
全部标签 我正在尝试弄清楚如何进一步解决此问题。我还想知道如何安装更新版本的ld(如果有意义的话)。所有涉及的包管理器都告诉我,我是最新的。代码在ubuntu12.04和12.10上使用g++(4.7.2)编译、链接和运行,但在FC17上编译失败并出现此错误。ArchiveServiceLib/debug-posix/libArchiveLib.a(NamedIflTiffCache.o):(.rodata._ZTV26UnlockingGenericFileHandle[_ZTV26UnlockingGenericFileHandle]+0x58):undefinedreferenceto`I
这个问题在这里已经有了答案:Whycantemplatesonlybeimplementedintheheaderfile?(17个答案)关闭9年前。我正在尝试编写一个玩具程序来练习C++,但我遇到了一个我无法解决的奇怪的undefinedreference错误。我的代码由3个文件组成:ex13_6.h:#includenamespaceex13_6{templateclassCmp{public:staticinteq(Ta,Tb){returna==b;}staticintlt(Ta,Tb){returna>voidbubble_sort(std::vector&v);}ex13_
我正在尝试学习如何将lua嵌入到C程序中,但我不擅长阅读技术文档,而且我还没有找到任何当前教程。这是我的程序:#include#include#include#includevoidreport_errors(lua_State*,int);intmain(intargc,char**argv){for(intn=1;n编译器给出了luaL_newstate、luaL_openlibs、luaL_loadfilex、lua_pcallk和lua_close的undefinedreference错误。我在一台Windows计算机上使用Code::Blocks,我已将luainclude目
我正在使用boost::interprocess在进程之间共享对象。我有两个文件,一个生成结构对象并将该对象传递到具有int索引的映射中的“server.cpp”;和一个“client.cpp”文件,它检索内存数据并遍历数据,输出到控制台。结构看起来像这样:structmydatao{stringMY_STRING;intMY_INT;};和对象:mydatao;o.MY_STRING="hello";o.MY_INT=45;服务器和客户端都能正确编译。但是出于某种原因,如果我尝试访问客户端中的字符串而不是float或整数,客户端可执行文件会抛出段错误。例如下面的second.MY_I
这个问题在这里已经有了答案:Whendoesinvokingamemberfunctiononanullinstanceresultinundefinedbehavior?(2个答案)关闭4年前。在下面的代码中,我在范围内创建了一个shared_ptr并将其分配给一个weak_ptr。为什么在运行代码时我没有得到SEGFAULT,因为wp应该在范围之外无效,对吧?namespace{structDummy{intx;voidfoo(){std::coutwp;{autosp=std::make_shared();wp=sp;}wp.lock()->foo();};
我将我的C++工具链从VisualStudio2013更新到VisualStudio2017/2019。现在我遇到了一些形式的编译错误:(13):errorC2280:'OfflineFixture::OfflineFixture(constOfflineFixture&)':attemptingtoreferenceadeletedfunction(8):note:compilerhasgenerated'OfflineFixture::OfflineFixture'here(8):note:'OfflineFixture::OfflineFixture(constOfflineFi
我曾尝试查看类似的问题,但无法轻易找到对我的问题有所帮助的问题。我用C++创建了一个项目,并在UNIX上编译、链接和运行它。我的具体问题是对我在单独文件中声明的方法的undefinedreference。在文件SharedCache.cpp中,我有以下方法:intSharedCache::replaceLine(ullongaddress){intevictPID=-1;intcacheSet=calcCacheSet(address);//randomuniformly-distributedvalueforcachelinefloatnumLines=static_cast(CAC
我目前正在尝试安装moses脚本,它是机器翻译工具moses的一部分,但不断出现错误:/home/moses/scripts/training/lexical-reordering/reordering_classes.cpp:349:undefinedreferenceto`gzopen'/home/moses/scripts/training/lexical-reordering/reordering_classes.cpp:353:undefinedreferenceto`gzwrite'/home/moses/scripts/training/lexical-reorderin
我有一个SuperParent类,一个Parent类(派生自SuperParent)并且都包含一个shared_ptr到一个Child类(它包含一个weak_ptr到一个SuperParent)。不幸的是,我在尝试设置Child的指针时遇到了bad_weak_ptr异常。代码如下:#include#include#include#includeusingnamespaceboost;classSuperParent;classChild{public:voidSetParent(shared_ptrparent){parent_=parent;}private:weak_ptrpare
我有一个SpriteManager类,它为我加载和缓存Sprite,并从缓存中删除未使用的Sprite。无论如何,这就是我的想法,我有点卡住了。我有一个map>我在其中存储Sprite,并使用weak_ptr生成shared_ptr的。现在我正在尝试使用一个删除器,它也从map中删除位图,它看起来像这样(显然不起作用):[&bitmaps](ALLEGRO_BITMAP*bmp){for(autoit=bitmaps.begin();it!=bitmaps.end();++it){if((*it).second==bmp){bitmaps.erase(it);al_destroy_bi