-
Errors Manifold
What do the following errors mean?
1. variable-size type declared outside of any function
2. no match for 'operator!=' in 'e[temp]!='\000''
candidates are BOOL operator!=(const GUID&, const GUID&)
First case, the error line is one where I declared an object-array with a variable as length, and I wanted the array to be global)
Second case is - for(temp=0; e[temp]!='\0'; temp++)
(temp is an global integer, e[] is a object-array.
Thanks.
-
"variable sized type" is when you have something like:
Code:
int size = 100;
char array[size];
The fix is to make "size" a const.
What is "e[temp]"? Is it perhaps of type GUID, in which case, it appears, that you can't compare it with a char - you may need to create a "NUL-GUID" or some such to compare your GUID value with, perhaps.
If this doesn't help, please post a section of the code you are having problems with.
--
Mats
-
1. Variable-size arrays are not standard in the first place (some compilers support them by extension because they exist in C99) and do not miraculously substitute dynamically allocated arrays.
2. I suppose there is no GUID constuctor that can make a GUID instance out of a character.
In addition limit the usage of global variables. There is no need to use a global variable for a loop counter (or a global variable called temp - a global variable is not temporary).
-
@matsp- A const is just what I dont want to make it
@anon - "and do not miraculously substitute dynamically allocated arrays."
That's nailed it, then.
I dunno what's a GUID....e[] is just the same object array mentioned in case 1, and temp is just to calculate a position in it.
Thanks.
-
Ehm, "object array" is obviously not, say, a character array - and you are trying to compare with a character - which is why the compiler is complaining. And as far as I can tell, it looks like your class for the object is "GUID" - but perhaps thats just an artifact of something else that the compiler is utterly confused about.
GUID in generally stands for "Globally Unique IDentifier", but there's other meanings too.
--
Mats
-
Omfg I went and confused it with a character array which has an '\0' in the end to help in comparison...Pwnd. I am using the dynamic memory allocation method now, which should've bin done ages back...