Author Topic: 2 functions in diffrent c files that have the same name  (Read 9102 times)

Offline erezz

  • Multiple posting newcomer
  • *
  • Posts: 53
Re: 2 functions in diffrent c files that have the same name
« Reply #15 on: November 05, 2013, 02:58:44 pm »

Thanks for the answer. I didn't know that c::b is limited to 1 binary per project. I hope this will be fixed in the future.

I guess that many programmers have a project with one big binary and many unit tests (each unit test is a stand-alone binary), so creating a project per unit test is problematic. In my case, I will need to have ~50 projects in my workspace.

BTW - even people that use custom Makefiles need an IDE...

Thanks,
Erez

Did you try to use targets (which are like different builds under the same project) to accomplish what you are trying to do? That would be a better option imo.


yes, I am using targets, but for a different purpose (debug mode target, release mode target etc).

Erez

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: 2 functions in diffrent c files that have the same name
« Reply #16 on: November 05, 2013, 03:48:15 pm »
Thinking about OPs problem some more I believe this is something we should eventually try to fix - it's a bug. It's perfectly reasonable that in two different implementation files we reuse the same symbol/function spec and maybe for totally different purposes. I've rejigged OP's project to use our build system with targets for each executable in the attachment. Now open the project, switch to the symbol tab, show "Current file's symbols" and double click on main or foo1 and see you will always be taken to the same file no matter which one is active. For someone interested in say, project refactoring, I think CC should keep data about all copies around.

[attachment deleted by admin]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12810
    • Travis build status
Re: 2 functions in diffrent c files that have the same name
« Reply #17 on: November 05, 2013, 03:53:42 pm »
dmoore: +1 here, also it is perfectly valid case if a function is defined either in anonymous namespace or with static storage specifier.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5237
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: 2 functions in diffrent c files that have the same name
« Reply #18 on: November 06, 2013, 03:47:35 pm »
Wow, there are a lot of discussion here, I have not read all of the replies, going to bed now :)

But for the issue reported by OP, I think there is already a solution:
See Several improvements to Code Completion plugin, especially the patch named: cc_build_target_handling.patch

This will parse the file in "active target scope", not the whole cbp project, so hope the OP can try apply the patch to see the result.



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.