Author Topic: CC doesn't work inside case  (Read 6131 times)

Offline hongruiqi

  • Single posting newcomer
  • *
  • Posts: 3
CC doesn't work inside case
« on: March 01, 2010, 10:43:30 am »
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
    }
.......
}

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: CC doesn't work inside case
« Reply #1 on: March 01, 2010, 12:52:44 pm »
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?

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: CC doesn't work inside case
« Reply #2 on: March 01, 2010, 02:47:05 pm »
Wow, Eclipse CDT work fine. :lol:

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5721
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CC doesn't work inside case
« Reply #3 on: March 02, 2010, 03:21:05 am »
See the code snippets in parserthread.cpp
Code
        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.