error C2133: <My_Struct> : unknown size-VBForums
Results 1 to 8 of 8

Thread: error C2133: <My_Struct> : unknown size

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    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.


  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  3. #3

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    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.


  4. #4
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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


  5. #5

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    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.


  6. #6

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    LOL, just seen the dumb-ass mistake in my original code. The error was in the line "struct pVarVals VariableValue[MAXVARIABLES];" The pVarVals and VariableValue were the wrong way round!

    Interesting error message though, and i suppose i could use that as an excuse....


    Thanks for the help though.
    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.


  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  8. #8

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.