News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

CC doesn't work inside case

Started by hongruiqi, March 01, 2010, 10:43:30 AM

Previous topic - Next topic

hongruiqi

CC doesn't work inside case
code:
typedef struct _me
{
    int X;
   int Y;
}me;
------------------------
int i=0;
switch(i)
{
    case 0:
    {
          me temp;
          temp.   //here it doesn't work
    }
.......
}

blueshake

of course it don't work because it is not parsed.And it is not easy to do this.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Loaden

Wow, Eclipse CDT work fine. :lol:

ollydbg

See the code snippets in parserthread.cpp
        else if (   (token==ParserConsts::kw_while)
                 || (token==ParserConsts::kw_if)
                 || (token==ParserConsts::kw_do)
                 || (token==ParserConsts::kw_else)
                 || (token==ParserConsts::kw_for)
                 || (token==ParserConsts::kw_switch) )
        {
            if (!m_Options.useBuffer || m_Options.bufferSkipBlocks)
                SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
            else
                m_Tokenizer.GetToken(); //skip args
            m_Str.Clear();
        }

So, you know, all the statement under "switch" clause was skipped.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.