-
Nov 17th, 2003, 12:40 PM
#1
Thread Starter
Not NoteMe
error C2133: <My_Struct> : unknown size
I have the code below:
Code:
#define MAXVARIABLES 127
#define MAXVARLENGTH 127
struct VariableValue
{
char variable[MAXVARLENGTH];
int value;
};
struct pVarVals VariableValue[MAXVARIABLES];
When i try to compile i get the error message above (subject of this thread).
I looked at the MSDN, and it didn't really say much: only that you aren't allowed to use arrays as part of a structure, when you have the '/Za' compile directive.
Can u just compile without this directive, or will it likely screw up something?
Thanks for any help you may provide.
EDIT: Had a look in project options and have found where i think /Za should be and it isn't, so if disabling it is the best option, then please explain how. Cheers.
Last edited by SLH; Nov 17th, 2003 at 12:46 PM.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts.
-
Nov 17th, 2003, 04:35 PM
#2
Isn't /Za the ANSI compatibility switch? I don't see why you shouldn't have arrays in structs, I've never heard of anything like it.
All the buzzt
CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 17th, 2003, 06:41 PM
#3
Thread Starter
Not NoteMe
Thanks for your reply.
In the MSDN it does mention something about the /Za switch being the 'The /Za (ANSI C)' switch. Not sure what this meens though. Expecially since i don't have it enabled (i don't think).
Below are the ones that i have in the project options:
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/Lex.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
As far as i know these are the normal switches/options as i havn't changed any, so i have no idea what's causing the error.
Any advice??
Thanks again.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts.
-
Nov 17th, 2003, 07:44 PM
#4
Frenzied Member
I am trying to figure out what you are doing. I am guessing you want another struct called pVarVals that has an element that is an array of the VariableValue with the size of MAXVARIABLES?
If this is right then you need to give the array element a variable name. So I think your code needs to be:
Code:
struct VariableValue pVarVals[MAXVARIABLES];
or
struct pVarVals
{
VariableValue Values[MAXVARIABLES];
};
Or you can nest the structs:
struct pVarVals
{
struct VariableValue
{
char variable[MAXVARLENGTH];
int value;
};
VariableValue Values[MAXVARIABLES];
};
But again I am not sure what you are trying to do.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com
-
Nov 17th, 2003, 08:49 PM
#5
Thread Starter
Not NoteMe
What i want is an array of a structure that stores a variable's name, along with a value associated with it.
The variable'ss name is an array of type char, and the value is of type int.
The structure holding the variable name + value i've called VariableValue, and the array of this structure i've called pVarVal.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts.
-
Nov 17th, 2003, 08:58 PM
#6
Thread Starter
Not NoteMe
-
Nov 18th, 2003, 05:12 AM
#7
A weird detail of C:
struct undeclared *pStruct;
is valid code, even if you never have declared or defined a struct called undeclared, simply because the struct keyword makes it a declaration.
However, you may only define pointers to undefined structs, not actual instances (such as normal variables or, like you, arrays).
This means that with this line:
struct pVarVals VariableValue[MAXVARIABLES];
you declared an array of size MAXVARIABLES called VariableValue of type struct pVarVals. pVarVals is thus declared, but not defined. Missing the definition, the compiler doesn't know the size of the struct and cannot create the array. Leaving you with this cryptic error message.
All the buzzt
CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 18th, 2003, 06:25 AM
#8
Thread Starter
Not NoteMe
Ah ha. Thanks for the explanation, that made it much clearer.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|