Using unspecified std::_ARRAY in structs after VC++2005

69 views Asked by At

I am migrating an old project up to be compiled in newer versions of Visual Studio. I am getting a compiler error C4430 while compiling an old struct:

struct SHOP_ITEM_LIST
{
char title[50];
char description[200];
_ARRAY(SHOP_ITEM);     // Another Struct with some integer and char array values
};

I researched that error and made out that since VC++2005, missing type specifiers aren't allowed anymore. It's not being interpreted as integer anymore.

I am not familiar with std::_Array< _Tp > and dont know how it behaves when being used in a struct with sizeof(). Would int _ARRAY(SHOP_ITEM); just do the trick, or would it manipulate the size of the struct?

What is the proper way to upgrade this struct to VC++2005 and later?

1

There are 1 answers

5
Ross Ridge On

It won't work if you put another type like int in front of it. It also won't work if you simple replace it with a template like std::_Array. It's clear from the context that _ARRAY was a macro.

I don't believe the definition for _ARRAY was provided by your Visual C++ 6 compiler. You should try to find out where it comes from. The simple fix may be to just include the file that defines it.

Failing that then the _ARRAY macro was probably defined either something like this:

#define _ARRAY(type) type _array_##type[1]

or like this:

#define _ARRAY(type) type *_array_##type

There should also be other macros that your code uses to do allocations and to access elements of the shop item array. Do you see other identifiers similar _ARRAY in your code? They wouldn't necessarily generate compile time errors, as they would probably look like undeclared functions to the compiler, however you'll need to implement them as well.