V
V
vvafree2017-02-17 09:51:23
visual studio
vvafree, 2017-02-17 09:51:23

Problems compiling in visual studio 2015 after adapting with visual studio 2010. What should I do?

The project was written in visual studio 2010. I translated it into visual studio 2015, but problems started to arise. I got rid of almost all of them, but the problem with std::array remained.
The Form1.h file, as I understand it, is a file for the form designer.

Example::top_cornea = gcnew array<int>(bmp->Width);
 Example::bottom_cornea = gcnew array<int>(bmp->Width);
 Example::x1_width= gcnew array<int>(bmp->Width);
 Example::x2_width= gcnew array<int>(bmp->Width);
 Example::width_cornea= gcnew array<int>(bmp->Width);

It writes errors:
1. A type specifier is required
2. Not enough arguments for the std::array class template
I searched the Internet, found such an option, but the errors do not disappear.
Example::top_cornea = gcnew array<int, (bmp->Width)>;
 Example::bottom_cornea = gcnew array<int, (bmp->Width)>;
 Example::x1_width= gcnew array<int, (bmp->Width)>;
 Example::x2_width= gcnew array<int, (bmp->Width)>;
 Example::width_cornea= gcnew array<int, (bmp->Width)>;

I've been digging for the second day already, I would have already redid this form, but the code is not mine, I'm afraid to dig even more.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
1
15432, 2017-02-17
@vvafree

Looks like using namespace std was added somewhere, causing array to be recognized as std::array instead of cli::array
Either remove using namespace std or explicitly specify cli wherever needed:
gcnew cli::array(...

A
Ariox41, 2017-02-17
@Ariox41

std::array is created on the stack as a regular sish array and requires the size to be specified at compile time, something like this: std::array<int, 3> array = {1, 2, 3};
Edit: Perhaps something else is needed there, but somewhere using namespace std
Edit is used: Didn't get into the second part right away. The template parameter must be known at compile time, i.e. bmp->Width must be constexpr or statc constexpr with the appropriate referencing syntax. Dynamic arrays in C++ are std::vector, you most likely used array from CLI, but I don't understand CLI.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question