Visual Studio 2013 中的C++ - <Class> 未定义

C++ in Visual Studio 2013 - <Class> is undefined

本文关键字:lt gt 未定义 Class Studio 2013 中的 C++ Visual      更新时间:2023-10-16

我对C++/VS很陌生,可能在我的项目的代码/配置中缺少一些东西。在我的解决方案中,我有两个项目:

  • 第一个是我下载的NTLhttps://bitbucket.org/ben_key/ntl,并编译为静态库NTL.lib
  • 一个"测试"项目,其中:(1)我通过在属性->C++->附加包含文件中指定其目录来添加头文件,(2)在属性->链接器->输入->附加依赖项中我添加了"NTL.lib"(3)将NTL.lib文件复制到与"测试"项目的主cpp文件相同的目录中

我的cpp只包含:

#include <NTL/GF2X.h>
int main() {
    GF2X P;
    return 1;
}

构建提供输出:

1>------ Build started: Project: test, Configuration: Release Win32 ------
1>C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V120Microsoft.CppBuild.targets(388,5): warning MSB8028: The intermediate directory (Release) contains files shared from another project (ntl-test.vcxproj).  This can lead to incorrect clean and rebuild behavior.
1>  QuickTest.cpp
1>..testsQuickTest.cpp(43): warning C4101: 'n' : unreferenced local variable
1>D:studiesThesisNTL-Ben-KeyIncludeNTL/vector.h(79): warning C4291: 'void *operator new(size_t,_ntl_vector_placement)' : no matching operator delete found; memory will not be freed if initialization throws an exception
1>          D:studiesThesisNTL-Ben-KeyIncludeNTL/vector.h(36) : see declaration of 'operator new'
1>          D:studiesThesisNTL-Ben-KeyIncludeNTL/vector.h(319) : see reference to function template instantiation 'void NTL::BlockConstruct<T>(T *,long)' being compiled
1>          with
1>          [
1>              T=NTL::zz_p
1>          ]
1>          D:studiesThesisNTL-Ben-KeyIncludeNTL/vector.h(291) : while compiling class template member function 'void NTL::Vec<NTL::zz_p>::DoSetLength(long)'
1>          D:studiesThesisNTL-Ben-KeyIncludeNTL/vector.h(115) : see reference to function template instantiation 'void NTL::Vec<NTL::zz_p>::DoSetLength(long)' being compiled
1>          D:studiesThesisNTL-Ben-KeyIncludeNTL/vec_lzz_p.h(14) : see reference to class template instantiation 'NTL::Vec<NTL::zz_p>' being compiled
1>  MyTest.cpp
1>MyTest.cpp(4): error C2065: 'GF2X' : undeclared identifier
1>MyTest.cpp(4): error C2146: syntax error : missing ';' before identifier 'P'
1>MyTest.cpp(4): error C2065: 'P' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

这真的是一件简单的事情,我没有弄清楚我错过了什么。

来自NTL/include/NTL/tools.h:

#define NTL_NAMESPACE NTL
#define NTL_OPEN_NNS namespace NTL_NAMESPACE {
#define NTL_CLOSE_NNS  }

因此,当预处理器遇到NTL_OPEN_NNS时,就像包含文件GF2X.h中的情况一样,它将其扩展为namespace NTL,这意味着GF2X类在名称空间NTL中声明。为了使用它,您需要将其完全限定为NTL::GF2X,或者使用using namespace NTL来讨论(例如)此处的哪一个。同样,在GF2X.h的末尾,在展开NTL_CLOSE_NNS 后有一个闭合括号