Author Topic: Global static objects ignored by CC  (Read 8151 times)

Offline ptDev

  • Almost regular
  • **
  • Posts: 222
Global static objects ignored by CC
« on: April 29, 2010, 12:22:23 am »
I noticed just now that code completion is very thorough while analysing the scope of declared objects, but to the extreme of ignoring global static objects. Is this behaviour intentional?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Global static objects ignored by CC
« Reply #1 on: April 29, 2010, 04:44:00 am »
I noticed just now that code completion is very thorough while analysing the scope of declared objects, but to the extreme of ignoring global static objects. Is this behaviour intentional?
Ok, I don't fully understand what's your meaning. Can you give a simple test code?

eg:

Code
//global static objects
static int aaa;
???

BTW:The parserthread.cpp do the whole "syntax analyze" job, and this file is quite easy to understand.
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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Global static objects ignored by CC
« Reply #2 on: April 29, 2010, 06:28:05 am »
Probably you should start with telling us the version of C::B you are using.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ptDev

  • Almost regular
  • **
  • Posts: 222
Re: Global static objects ignored by CC
« Reply #3 on: April 29, 2010, 08:24:57 am »
Probably you should start with telling us the version of C::B you are using.

I apoplogize, I wrote this quite late last night, and was a bit too tired to explain properly.

I am running Code::Blocks svn revision 6202, built with MinGW-TDM 4.4.1-2 and wxWidgets 2.8.10.
The code which CC didn't parse properly was something similar to:

Code
#include "myarray.h"
#include "myclass.h"

static myspace::myarray a;  // Global static objects typed before any myclass member functions
static myspace::myarray b;

// ...

void myclass::method()
{
   a.  // ... <-- Here, I typed the access operator, but the CC member list did not appear

}

However, declaring local objects from the same namespace and class resulted in the expected behaviour:

Code
void myclass::method()
{
   myspace::myarray a;
   a.  // ... <-- Here, the CC member list appeared normally

}

If I switched between ommiting the local object or not, so would the CC tooltip disappear or reappear.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Global static objects ignored by CC
« Reply #4 on: April 30, 2010, 03:17:02 am »
Ok, I have just test the sample code like below with our parserTest project.

Code
namespace myspace {

class myarray{
public:
int m_aaa;
}

};

 myspace::myarray a;  // Global static objects typed before any myclass member functions
 myspace::myarray b;

And the output of the parser is like below:
Code
...

000058. namespace namespace myspace {...} [1,1]
000059. class class myarray {...} [3,0]
000060. variable int myspace::myarray::m_aaa [5,0]
000061. variable myarray myspace::a [10,0]
000062. variable myarray myspace::b [11,0]

And if I add the "static" before the statement, I found that the parser give the same result:
Code
...
--------------L-i-s-t--L-o-g--------------

000060. namespace namespace myspace {...} [1,1]
000061. class class myarray {...} [3,0]
000062. variable int myspace::myarray::m_aaa [5,0]
000063. variable myarray myspace::a [10,0]
000064. variable myarray myspace::b [11,0]

So, as a conclusion, I think parser works as expected. So, maybe there's a bug in other part of CC.  :D
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.