C++ CLI - 错误 C2976:'std::tr1::array':MS C++ Express 2010 中的模板参数太少
c++ cli - error C2976: 'std::tr1::array' : too few template arguments in MS C++ express 2010
我正在C++Express 2010中处理一个Windows窗体项目。对Form.h进行了一些更改,现在在编译程序时出现错误。请注意,编译器建议错误在主程序open gl test 2
中,即#includes
的形式。在我开发代码的过程中,所有程序都编译了好几天,然后昨晚更改了一些内容,现在我得到了错误。
open gl test 2中的主程序与我创建的任何其他基于表单的项目的主程序相同-我将其与check进行了比较[除了名称空间等的明显变化导致它是一个不同的项目]
// open gl test 2.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
using namespace opengltest2;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
错误为:
1>open gl test 2.cpp(9): error C2976: 'std::tr1::array' : too few template arguments
1> D:Program Files (x86)Microsoft Visual Studio 10.0VCincludearray(18) : see declaration of 'std::tr1::array'
1>open gl test 2.cpp(9): error C3699: '^' : cannot use this indirection on type 'std::tr1::array'
1> compiler replacing '^' with '*' to continue parsing
编译器抱怨的行是
int main(array<System::String ^> ^args)
因此,错误不可能出现在编译器声称的地方——我在包含的文件中的代码中找不到错误——它们编译正确。我认为错误一定是形式.h,因为这就是我修改的导致这个错误的原因,但我看不到。我很确定我没有更改一些项目设置。
我没有包括form1.h的代码,因为它太长了。我想我要找的是人们寻找错误的经验。我可以使用什么策略来解决这个问题?如果我有头发要拔,我会被它包围。请帮我保存我不存在的头发。
编译器似乎混淆了托管数组类型和std库中的数组类型。这可能是因为在执行using namespace std
时,理想情况下应该显式引用正确的命名空间(std::array或cli::array(,或者在不需要的情况下删除<array>
的include。
请注意,常量大小的std::array不适合与命令行参数一起使用——无论如何,您都需要使用像cli::array这样的可变大小容器。
相关文章:
- 无法在 Visual Studio 2010 中构建 Allegro C++ 程序
- Visual Studio 2013,错误 MSB8020:找不到 Visual Studio 2010 的生成工具
- VisualC++ 2010 有没有办法找出有关未处理异常错误的更多详细信息
- 双线程应用比单线程应用慢 C++ (VC++ 2010 Express).如何解决?
- std::array initalization with Visual Studio 2010
- MSVC 2010 编译应用程序和 MSVC 2019 编译应用程序之间的行为差异
- 将代码从 32 位迁移到 64 位时出现问题 Visual Studio 2010
- 在 Visual Studio 2010(及更高版本)中定义包含或链接路径变量的位置
- Visual Studio 2010 单元测试:无法识别引用的项目类
- Visual Studio 2010 - C++ 致命错误 LNK1120: 1 个未解析的外部
- VisualStudio 2015 链接器查找 VS 2010 库
- C /FORTRAN项目由Visual Studio 2010/Intel 2013创建,将不会在Visual St
- 如何使 Visual Studio 2010 警告未使用的变量
- 如何解决错误 C2719 在 Visual Studio 2010 C++ 中不存在代码行时
- 代码 c++ VS 2010 中的 LPCWSTR 到字符串转换问题
- 按值传递的参数在 Visual Studio 2010, C++ 的调试器中显示为通过引用传递
- Visual Studio 2010 是否执行零初始化
- 从另一个CPP文件访问Form1的文本框,Visual C 2010
- 无法使用 Visual Studio 2010 和 Qt 版本 4.8.0 创建"Qt Gui Application"
- 从 Visual C++ 2010 中的单独线程调用消息框