Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ code browser in eclipse

I'm using Eclipse Indigo while programming on c++. I'm using a code that provides extensive doxygen comments. I'd like to be able to see them inside eclipse, without having to use an external browser. I think the javadoc equivalent for that would be shift+F2, but it doesn't work with c++ doxygen.

To put it in other words, when my mouse hovers over a method of a class, the tool tip provides the implementation of the function (found in the .cpp), instead of its declaration and the comments associated with it (found in the .h). I would like to see the latter in my tooltip.

Is there a solution for c++ users ?

Thanks

like image 442
bob Avatar asked Apr 10 '12 13:04

bob


1 Answers

Unfortunately it's not possible and I doubt it will be ever possible in future. To explain in detail, read further.
In C++ you can write a function in 2 ways.

  1. Directly define the function (may be extern, inline or static)
  2. Declare the function in a header and then define the function in implementation file

Now eclipse chooses the implementation always and the reason for that is consistency. In C++ (unlike Java) you can have many forward declarations of a function in several header file, however the definition is always 1 (ODR).
If you bring the function under mouse, then which declaration to choose ? So it's better to choose a definition. Though this problem may not occur in the case of class methods.

Coming back to your question:

the tool tip provides the implementation of the function, instead of its declaration and the comments associated with it

The best way is to have comments embed with the implementation of the function. In other words, choose style-2 from below:

style-1

class A {
 ...
public:
  /*
   * description of the function
   */
  void foo ();
};
void A::foo ()
{
...
}

style-2

class A {
 ...
public:
  void foo ();
};

/*
 * description of the function
 */
void A::foo ()
{
...
}

Workaround: Press the F3 key twice and it will lead you to the declaration via the definition.

like image 78
iammilind Avatar answered Sep 28 '22 01:09

iammilind