我正在使用C++ Express 2010中的Windows窗体项目.对Form.h进行了一些更改,现在编译程序时出现错误.注意编译器显示错误是在主程序- open gl test 2-即#includes形式.在我开发代码时,所有编译好了好几天,然后昨晚改变了一些东西,现在我得到了错误.
open gl test 2中的主程序与我创建的任何其他基于表单的项目相同 - 我比较检查[除了命名空间的明显变化等导致其不同的项目]
// 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;
}
Run Code Online (Sandbox Code Playgroud)
错误是:
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.0\VC\include\array(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
Run Code Online (Sandbox Code Playgroud)
编译器抱怨的是
int main(array<System::String ^> ^args)
Run Code Online (Sandbox Code Playgroud)
因此,故障不在编译器声称的位置 - 我无法在包含的文件中找到代码中的错误 - 它们可以正确编译.我假设错误必须在form.h中,因为我修改了导致此错误,但我看不到它.而且我很确定我没有更改某些项目设置.
我没有包含form1.h的代码,因为它太长了.猜猜我正在寻找的是人们搜索错误的经验.我可以用什么策略来解决这个问题?如果我把头发拉出来,我会被它包围.请帮我保存不存在的头发.
The*_*ees 15
看起来编译器在托管数组类型和std库中的数组类型之间变得混乱.这可能是因为你正在做的某个地方using namespace std- 理想情况下你应该明确地引用正确的命名空间(std :: array或cli :: array),或者<array>如果不需要则删除include .
请注意,常量大小的std :: array不适合与命令行参数一起使用 - 你需要使用像cli :: array这样的可变大小容器.