Author Topic: CC with namespaces  (Read 6287 times)

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
CC with namespaces
« on: July 31, 2012, 03:41:03 am »
I have been doing some work with OpenCV, and noticed that code completion appears to fail when namespaces are used.
For example:
Code
cv::Mat myMat;
myMat. // CC works here

But:
Code
using namespace cv;
Mat myMat;
myMat. // CC fails to launch

Is this a known shortcoming of the parser?  Is there a setting somewhere that I am missing?
(Code::Blocks rev 8160, OpenCV 2.4.2, Windows XP and Vista)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CC with namespaces
« Reply #1 on: July 31, 2012, 04:29:16 am »
Both of the code snippet works here, they give the same suggestion list.
OpenCV 2.1, C::B nightly build, WinXP.

You can help to debug it by enable the smartsense log message, see:
8.4 Debug Smart Sense log output
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 Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: CC with namespaces
« Reply #2 on: July 31, 2012, 10:53:16 pm »
Strange... I cannot seem to reproduce the behavior now.  I will post again if I figure out in what situations it used to occur.

(I wonder what I changed?!)

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: CC with namespaces
« Reply #3 on: August 01, 2012, 04:57:28 am »
If the using namespace line is placed in a header file, code completion fails within source files including it (but not specifying the namespace themselves).

Also, these typedef's from opencv2/core/core.hpp are not picked up:
Code
/*!
  \typedef

  shorter aliases for the most popular cv::Point_<>, cv::Size_<> and cv::Rect_<> specializations
*/
typedef Point_<int> Point2i;
typedef Point2i Point;
typedef Size_<int> Size2i;
typedef Size2i Size;
typedef Rect_<int> Rect;
typedef Point_<float> Point2f;
typedef Point_<double> Point2d;
typedef Size_<float> Size2f;
typedef Point3_<int> Point3i;
typedef Point3_<float> Point3f;
typedef Point3_<double> Point3d;

You can help to debug it by enable the smartsense log message
I enabled it, and now there is a lot of output; but what do I do with the log?  Is there something specific I should be looking for?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: CC with namespaces
« Reply #4 on: August 01, 2012, 06:17:45 am »
You can help to debug it by enable the smartsense log message
I enabled it, and now there is a lot of output; but what do I do with the log?  Is there something specific I should be looking for?
For the things with the typedefs you can also use the cc_test tool - a project within the CC plugin's sources. Then post the log here. These typedefs actually should work. What are your settings in CC?
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