Author Topic: Finding decleration/implementation of a function/class in C++ using CodeBlocks I  (Read 5968 times)

Offline slalom3

  • Multiple posting newcomer
  • *
  • Posts: 10

I am using a library that is written in our university,in our code/program that I call it "X" for the sake of simplicity. I created a path to the library, in "bashrc" file and also made an environmental variable. The problem is I can just trace code X to some extents and then, in codeblocks when I try to find decleration/implementation of a function/class by right clicking on that I get an error "Not Found!".

This library includes nested files.For example, I have code X which uses namespace B, inside namespace B you can find a class named C,and inside that class (C), another class D is used in which (class D), the function F is defined!. So,when I am in code X,when function F is used I need to be able to trace the code to class D but I cannot. imagine in my example, I just can go from X to B by right clicking on a function and then, it stops there! if I try I get an error "Not Found!". it seems it cannot recognize the path of included files. It should be noted that this program/code (X) is compiled perfectly and works great! Also, cmake is used for compilation and I am using ubuntu.

And I have tried : Settings menu” and “Compiler Click the “Directories” tab add the path to the .h files for the library.... It does not work!!!

LAST thing my libraries and files are included correctly by "MY_LIBRARY" to the code.

I appreciate any suggestion.
« Last Edit: June 05, 2016, 12:31:58 am by slalom3 »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
The "find deceleration" function is (as far as i remember) part of the code completion plugin. Does code completion works? It may have problems with nested namespaces and classes...
I don't know if the clang cc has a better support for this: https://github.com/yvesdm3000/ClangLib
and
http://forums.codeblocks.org/index.php/topic,20623.0/topicseen.html

Quote
made an environmental variable
what is the name of this variable?

greetings

Offline slalom3

  • Multiple posting newcomer
  • *
  • Posts: 10
@BlueHazzard thanks for your answer.
Yes, code completion works.Honestly I have no idea what clang cc is! although  I took a look at your links.
Also,name of environmental variable is "STIM_PATH", I don't know why you ask this!! since it could be anything and it is found by the compiler.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Also,name of environmental variable is "STIM_PATH", I don't know why you ask this!! since it could be anything and it is found by the compiler.
I wanted to know if you manipulated the environment variable that goes straight to the compiler and not trough codeblocks. Because if you had done this, code blocks would have had no chance to detect the paths but compilation would have worked...

anyway as you say code completion is working, then find declaration should also work, i have no idea what is wrong...May be some one else can help you :)

clang cc is a alternative code completion plugin, that bases on the clang code parser...  On this links is somewhere written where you can get a pre build plugin, that should work..

greetings

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
@slalom3, thanks for the report, but I think the most important thing is: please give a minimal sample project, so that we can test the bugs, otherwise, we can't help much, because we need a way to reproduce this bug.
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 slalom3

  • Multiple posting newcomer
  • *
  • Posts: 10
Also,name of environmental variable is "STIM_PATH", I don't know why you ask this!! since it could be anything and it is found by the compiler.
I wanted to know if you manipulated the environment variable that goes straight to the compiler and not trough codeblocks. Because if you had done this, code blocks would have had no chance to detect the paths but compilation would have worked...

anyway as you say code completion is working, then find declaration should also work, i have no idea what is wrong...May be some one else can help you :)

clang cc is a alternative code completion plugin, that bases on the clang code parser...  On this links is somewhere written where you can get a pre build plugin, that should work..

greetings

Thanks though.

Offline slalom3

  • Multiple posting newcomer
  • *
  • Posts: 10
@slalom3, thanks for the report, but I think the most important thing is: please give a minimal sample project, so that we can test the bugs, otherwise, we can't help much, because we need a way to reproduce this bug.

Unfortunately, it is impossible to provide any "minimal sample project". Because like I said I am dealing with a library with nested classes and files.takes a couple of hours to install all the dependencies and compile it.
Sorry for that.
There must be a solution though!

Offline slalom3

  • Multiple posting newcomer
  • *
  • Posts: 10
@ollydbg I believe I found the problem!!! :)

look at the code below:

 
Code
if (header.data_type == envi_header::float32)
return ((bip<float>*)file)->co_matrix(co, avg, mask, PROGRESS);

co_matrix ia a function and codeblocks cannot find its deceleration/implementation.I think the reason is using"   -> "  !
because it also happens in other similar cases.

Is there any way to solve it?
« Last Edit: June 05, 2016, 06:24:12 pm by slalom3 »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
@ollydbg I believe I found the problem!!! :)

look at the code below:

 
Code
if (header.data_type == envi_header::float32)
return ((bip<float>*)file)->co_matrix(co, avg, mask, PROGRESS);

co_matrix ia a function and codeblocks cannot find its deceleration/implementation.I think the reason is using"   -> "  !
because it also happens in other similar cases.

Is there any way to solve it?
OK, I see the issue.
The native code completion plugin can't solve this issue. The reason is that handling
Code
((bip<float>*)file)
is a bit complex for current implementation.
I mean it need handling operation precedence of an expression.
Hope some one can implement this(an easy way is to use bison), or you can try Clang code completion.  :)
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.