0

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?

Vinz
  • 3,030
  • 4
  • 31
  • 52

1 Answers1

0

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.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
  • Yeah there are other definitions like that in the project. But they sit in header files. I could not find a typedef or smth similar for _ARRAY in the whole solution. Also searching for the Definition of _ARRAY leads to nothing, and just highlights every _ARRAY in the code. So I researched the type and got this link (http://www.aoc.nrao.edu/php/tjuerges/ALMA/STL/html-4.1.2/structstd_1_1__Array.html). So I assume its the std::_ARRAY, but its kind of strange... I am not so familiar with C++ yet, and hoped it was a well known type :s – Vinz Aug 13 '14 at 01:06
  • No, it's not the `std::_Array` template you linked. As said it's a macro, a preprocessor macro created with a `#define` preprocessor directive. Something like one of the two examples I gave above. – Ross Ridge Aug 13 '14 at 01:09
  • It really is funny... The project was not changed at all. Just migrated from VC++6 to VC++2008 for a test, if it works. VC++6 compiles without a singe error, but doesnt finds the definition of _ARRAY either. VC++2008 says it cant compile because unspecified types are deprecated, but would compile with an "int" in front of it. It also cant find the definition of _ARRAY.... I will hang on searching for this in header files and if I dont succeed, I will have to rework every struct to use normal arrays... – Vinz Aug 13 '14 at 01:25
  • 1
    @user2334932: VC++6 too can stop compilation after preprocessing. That would allow you to verify whether `_ARRAY` is a macro, and if so, what it expands to. – MSalters Aug 13 '14 at 07:03
  • @MSalters that sounds great. Where does the preprocessor give some information about macros, and where they are expanded from? I see that I can stop compilations with #error, but I'm not sure if thats the thing which you have mentioned. – Vinz Aug 13 '14 at 08:53