error C2976: 'std::tr1::array' : too few template arguments in MS C++ express 2010

StackOverflow https://stackoverflow.com/questions/23405282

  •  13-07-2023
  •  | 
  •  

Frage

I'm working on a Windows forms project in C++ Express 2010. Made some changes to the the Form.h and now get an error when compiling the program. Note the compiler suggests the error is in the main program - open gl test 2 - that #includes the form. All compiled fine for days as I developed the code, then changed something last night and now I get the error.

The main program in open gl test 2 is identical to that of any other forms based project I have created - I've compared to check [except for the obvious changes of namespace etc cause its a different project]

// 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;
} 

The error is:

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

line that compiler is complaining about is

int main(array<System::String ^> ^args)

So the fault cant be in where the compiler claims it is - and I can not find a fault in the code in the included files - they compile correctly. I assume the error MUST be in form.h cause that's what I modified that causes this error, but I can not see it. And I'm pretty sure I did not change some project settings.

I ain't including the code for form1.h cause it's toooooo long. Guess what I'm looking for is peoples experience of searching for the error. What strategies can I use to resolve this? If I had hair to pull out I would be surrounded by it. Please help me save my non-existant hair.

War es hilfreich?

Lösung

It looks like the compiler is getting confused between the managed array type and the array type in the std library. This is probably because somewhere you're doing using namespace std - you should ideally explicitly reference the correct namespace (std::array or cli::array), or remove the include of <array> if it's not needed.

Note that the constant size std::array isn't suitable for use with command-line arguments - you'd need to use a variable size container like cli::array anyway.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top