草庐IT

MANAGE_EXTERNAL_STORAGE

全部标签

c++ - Unresolved external

我有一个Unresolvedexternalsymbol错误,这让我抓狂。简而言之,我有一个用于SDL_Surfaces('DgSurface')的包装类和一个用于加载和存储DgSurfaces('DgSurfaceList')的类。尝试在我的项目中包含DgSurfaceList文件时出现链接问题。这是我的类(class):头文件“DgSurface.h”包含DgSurface类声明:#ifndefDGSURFACE_H#defineDGSURFACE_H#include"SDL.h"#includeclassDgSurface{public://Constructor/destruc

C++ 错误 LNK2001 : unresolved external symbol function _main

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Whatisanundefinedreference/unresolvedexternalsymbolerrorandhowdoIfixit?我正在学习C++,但在我的项目中遇到编译问题。我已经阅读了大量标题上有此错误的帖子,但我找不到问题出在哪里。我的Main函数中有一个方法调用是导致错误的原因。每当我评论该项目编译完美的行。代码如下:main.cpp#pragmaonce#include"stdafx.h"#include#include#include#include#include#include"N

c++ - 带有 C++ 模板的虚假 "use of local variable with automatic storage from containing function"?

以下代码无法在g++7.2.0中编译templateclassRequest{intcontent=0;public:friendvoidsetContent(inti,void*voidptr){Request*ptr=(Request*)voidptr;ptr->content=i;}intgetContent(){returncontent;}};intmain(){Requestreq;setContent(4,&req);returnreq.getContent();}有错误test.cpp:Ininstantiationof‘voidsetContent(int,void*

c++ - 等价于 C 中的 std::aligned_storage<>?

在C语言中,有没有一种方法可以使堆栈上的存储过度对齐(即比从类型系统推断出的对齐更多)?对于动态分配的内存中的变量,如果所有其他方法都失败了,我们总是可以手动对齐,但是对于自动分配的内存中的变量可以做什么呢?我想可以使用char[size+alignment-1]然后总是使用位操作来访问变量,但这似乎比必要的“有点”暗淡(harharhar;)). 最佳答案 在C2011中,有_Alignas和_Alignof关键字,标题这使得它们的使用稍微不那么难看,类型max_align_t(在中)。例如,你可以写double_Alignas(

c++ - 链接器错误 'unresolved external symbol' : working with templates

我有一个基于模板的类[Allotter.h&Allotter.cpp]:templateclassAllotter{public:Allotter();quint32getAllotment(allotType*);boolremoveAllotment(quint32,intauto_destruct=0);private:QVector>indexReg;intinit_topIndex;};它的用法如[ActiveListener.h&ActiveListener.cpp]所示:classActiveListener:publicQObject{Q_OBJECTpublic:Ac

c++ - std::align 和 std::aligned_storage 用于内存块的对齐分配

我正在尝试分配一个大小为size的内存块,它需要Alignment对齐,而在编译时可能未定义大小。我知道存在_aligned_alloc、posix_memalign、_mm_alloc等例程,但我不想使用它们,因为它们会降低代码的可移植性。C++11提供了一个例程std::align和一个类std::aligned_storage,我可以从中检索POD类型进行分配一个将符合我的要求的元素。然而,我的目标是创建一个分配器,它将分配一个size大小的内存块(不仅仅是单个元素),该内存块将被对齐。这可能使用std::align吗?我问的原因是因为std::align移动指针,使用该指针的类

c++ - std::optional 实现为 union vs char[]/aligned_storage

在阅读GCC对std::optional的实现时,我注意到了一些有趣的事情。我知道boost::optional实现如下:templateclassoptional{//...private:boolhas_value_;aligned_storagestorage_;}但是libstdc++和libc++(以及Abseil)都像这样实现它们的可选类型:templateclassoptional{//...private:structempty_byte{};union{empty_byteempty_;Tvalue_;};boolhas_value_;}在我看来,它们在功能上是相同的

c++ - Glew 问题, Unresolved external 问题

我想开始使用OpenGL3+和4,但我在使用Glew时遇到了问题。我试图将glew32.lib包含在附加依赖项中,并且我已将库和.dll移动到主文件夹中,因此不应该有任何路径问题。我得到的错误是:Error5errorLNK2019:unresolvedexternalsymbol__imp__glewInitreferencedinfunction"void__cdeclinit(void)"(?init@@YAXXZ)C:\Users\Mike\Desktop\TestFolder\ModelLoaderthroughVBO\ModelLoader\main.objModelLoa

c++ - std::aligned_storage 的目的是什么?

如果我理解正确的话,std::aligned_storage的主要优点是它管理对齐。它还可以使用memcpy()进行复制,并且可以与POD类型一起使用。但是!1)POD类型默认由编译器对齐,我们可以使用#pragmapack(push,1)覆盖编译器的对齐方式2)默认情况下,我们可以使用memcpy()复制POD(我们不应该为此做些什么)所以我真的不明白为什么我们需要std::aligned_storage? 最佳答案 只要您希望将内存分配与对象创建分离,就可以使用std::aligned_storage。您声称:Alsoitisu

c++ - 错误 LNK2001 : unresolved external symbol (C++)

这个问题在这里已经有了答案:Whatisanundefinedreference/unresolvedexternalsymbolerrorandhowdoIfixit?(38个答案)关闭9年前。假设我在一个名为one.cpp的文件中有一个名为DoThis(constchar*abc)的函数。因此,当我尝试从另一个源文件(two.cpp)中的另一个函数调用此函数时,我收到错误:errorLNK2001:unresolvedexternalsymbol(C++),即使我使用了#include"one.h"我要解决这个问题吗?