草庐IT

c++ - 外部关键字 "missing type specifier"

我正在使用VisualC++Express创建一个DLL,并且在声明时externValveInterfaces*VIFace在Required.h中,编译器告诉我ValveInterfaces没有定义。(我想将VIFace暴露给任何文件,包括Required.h)这是我的文件结构:DLLMain.cpp#include"Required.h"//requiredheaderfiles,suchasWindows.handtheSDKValveInterfaces*VIFace;//therestofthefileRequired.h#pragmaonce//includeWindow

c++ - 为什么我的外部变量还没有初始化?

我正在使用两个编译单元编译一个共享库:globals.cpp和stuff.cpp。globals.cpp文件初始化了一些在stuff.cpp中使用的外部变量。我遇到的问题是stuff.cpp中的代码在globals.cpp中的代码有机会为外部变量赋值之前运行。例如,我看到正在使用一堆0值。这个问题取决于我在哪个平台上编译/运行代码——有些可以,有些则不能。如何解决这个问题?我可以强制globals.cpp先运行吗? 最佳答案 你不能(以一致的方式)但您可以解决它。全局.cpp//Ifyouhaveaglobalvariabletha

c++ - 双向链表 : Unresolved Externals

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Whycantemplatesonlybeimplementedintheheaderfile?Whatisanundefinedreference/unresolvedexternalsymbolerrorandhowdoIfixit?同样,这是一项家庭作业,我的导师给了我们很多反馈,但我仍然对这个编译问题一头雾水。当我将main函数放在实现文件中时,程序会编译并完美运行。但是,当我将main函数放入main.cpp时,编译器会提示:unresolvedexternalsymbol"public:__thi

c++ - 外部变量导致多重定义错误

我一直在尝试使用extern来使用之前定义的变量。我以前没有使用过extern,现在我需要使用它来只定义一次变量并在多个文件中使用它们我已经为这个问题编写了最小化版本的代码。我有四个文件库文件#ifndefLIB_H#defineLIB_H#includenamespacelib{externboolinitialized;boolinitialized=false;staticvoidisInit(char*parent){std::cout车辆.h#ifndef_VEHICLE_H#define_VEHICLE_H#includeclassVehicle{public:Vehicl

c++ - 在非函数调用相关声明上使用 "extern C"

我知道之前有人问过有关extern"C"的问题,但我收到的信号很复杂,希望有人能指出以下场景中的最佳实践。我已经为Linux编写了一个驱动程序,并定义了几个struct以及一些_IO、_IOR和_IOWioctl(...)调用的定义。我的结构都不包含任何函数,下面是我使用的struct、enum和ioctl示例:#ifdef__cplusplusextern"C"{#endifenumAlignment{Left=0,Right=1,Middle=3};structData{intSize;void*Address;};#definefoo_IOR(DRV_ID,1,structDat

c++ - "error LNK2001: unresolved external symbol"

这个问题在这里已经有了答案:Whatisanundefinedreference/unresolvedexternalsymbolerrorandhowdoIfixit?(38个答案)关闭5年前。我的VC++2008程序有问题。当我编译它时,列出了以下错误。我花了很多有时间上groups.google.com找原因,但是没有评论帮助过我。有人知道问题出在哪里吗?谢谢。errorLNK2001:unresolvedexternalsymbol"longrfl_xref_id"(?rfl_xref_id@@3JA)errorLNK2001:unresolvedexternalsymbol"

c++ - 在 VC++ 中解决 hid.lib "unresolved external symbol"链接器错误

如标题所示,我遇到以下链接器错误:errorLNK2019:unresolvedexternalsymbol"unsignedchar__stdcallHidD_GetAttributes(void*,struct_HIDD_ATTRIBUTES*)"(?HidD_GetAttributes@@YGEPAXPAU_HIDD_ATTRIBUTES@@@Z)在我的代码中调用result=HidD_GetAttributes(WriteHandle,&attributes)时。这个函数应该存在于“hid.lib”中,我已将其添加到项目的链接器依赖项中。我还包含了头文件“hidsdi.h”,它

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

在我之前编译良好的VC++代码中,我添加了一个函数X(),如下所示:InthefileBaseCollection.hclassBase{//codevirtualHRESULTX();//code};INthefileDerivedCollection.hclassDerived:publicBase{HRESULTX();}InthefileDerivedCollection.cppHRESULTDerived::X{//definitionofDerivedhere.}已将头文件正确地包含在.cpp文件中。但我仍然不明白为什么会出现链接错误:errorLNK2001:unreso

c++ - error LNK2019 : unresolved external symbol. c文件转cpp

有一个用C做的项目,它的文件是来自http://www.codeproject.com/Articles/185522/Using-the-Raw-Input-API-to-Process-Joystick-Input的RawInput.c。.我编译了它,它在vs2012中完美运行。但是当我在一个新项目的cpp中粘贴相同的代码时,我得到了其中的4个错误,只是不同的decleration名称。错误LNK2019:未解析的外部符号“long__stdcallHidP_GetCaps(struct_HIDP_PREPARSED_DATA....fatalerrorLNK1120:4个Unre

c++ - VC++ 中 Unresolved external 错误

我正在学习vc++,正在用代码查看内存的使用信息。这个程序给我三个Unresolvedexternal错误..errorLNK2019:unresolvedexternalsymbol_GetProcessMemoryInfo@12referencedinfunction"void__cdeclPrintMemoryInfo(unsignedlong)"(?PrintMemoryInfo@@YAXK@Z)errorLNK2019:unresolvedexternalsymbol_EnumProcesses@12referencedinfunction_mainerrorLNK1120: