An error like this is typically caused by a missing (full) declaration. In other words: One of your types is known due to a forward declaration, but the compiler doesn't know the actual structure of that type (which makes it impossible to know the length of that array or one of its elements).
Something like the following should cause the very same error:
struct Data;
Data myData[50]; // The compiler doesn't know how much data is needed
To solve this issue, you have to include the proper header file or add a full declaration (make sure to not duplicate definitions):
struct Data; // This line is now obsolete in this simple example
struct Data {
int someInteger;
};
Data myData[50]; // The compiler now knows this is essentially 50 integers (+padding)
Didn't notice that it's not just complaining about incomplete type
, but incomplete element type
.
This essentially means that C++ isn't able to determine the size of a multidimensional array.
If you'd like to define or pass an n-dimensional array, you have to keep in mind that you're allowed only one dimension of variable length (since the compiler won't be able to determine the correct size otherwise). In short, there must only be one occurrence of []
at most.
Here are some examples:
void doSomething(int args[]) {
// 1 dimension, every element is the length of one integer
args[0]; // this is the first integer
args[1]; // this is the second integer (offset is args + sizeof(int))
}
void doSomething(int args[][2]) {
// 2 dimensions, every element is the length of two integers
args[0]; // this is the first set of integers
args[1]; // this is the second set (offset is args + sizeof(int[2]))
}
void doSomething(int args[][]) {
// 2 dimensions, no idea how long an element is
args[0]; // this is the first set of integers
args[1]; // this is the second set (offset is args + sizeof(int[])... oops? how long is that?)
}
As a workaround, you can just pass pointers and hide the fact that you've got an array (since the length of pointers is known). Only downside to this is the fact that the compiler will no longer know that you're indeed passing an array rather than a single value (by reference).
void doSomething(int args*[]) {
// 2 dimensions, set of integers
args[0]; // this is the first set of integers
args[1]; // this is the second set (offset is args + sizeof(int*))
}
So going back to your actual problem:
Simply replace the line
int inStringArray(char*[][],int,char*);
with
int inStringArray(char**[],int,char*);
Just keep in mind you might have to update other portions of your code as well and you'll have to be careful in case you're passing that array somewhere (e.g. freeing it using delete
).