User forums > Using Code::Blocks
Bug in 'swap header / source'
ironhead:
I have a project that comprises many directories, and in those directories the same file names are generally repeated. Basically:
<root>
---<sub dir1>
Config.cpp
Config.h
---<sub dir2>
Config.cpp
Config.h
What I find is that if I open Config.cpp in <sub dir2> and right click on the tab and select 'swap header / source', I get Config.h from <sub dir1>.
What I find interesting is that if I go to the '#include <Config.h>' line in Config.cpp in <sub dir2> and right click and select 'Open #include file: Config.h', the proper Config.h (from <sub dir2>) is opened.
stahta01:
Might be a Code::Blocks bug.
FYI, You should be using '#include "Config.h"' instead of '#include <Config.h>' the "<>" means system header in many C compilers. But, this should not cause the problem you are seeing. I have no idea where to look for cause and not the time to duplicate it.
Tim S.
oBFusCATed:
I've observed the same bug/missing feature
ollydbg:
rev 5850
--- Quote ---* applied (modified) patch #2803 - faster header source swapping (thanks techy)
--- End quote ---
This function has recently improved. seems a regression. :D
Zini:
Confirmed. If there is more than one file with the same name, it is semi-random which file you get.
From looking at the source it seems like Code::Blocks is simply listing all possible directories and then picks a file with a suitable name. At least I guess that is what it is doing. A single function consisting of over 200 lines of codes (several screen pages) is a bit hard to parse. Am I the only one who thinks, that Code::Blocks is in dire need of some refactoring?
A quick fix might be to first look in the same direcotry as the original file. But actually the situation is a bit more complicated. Let's assume this directory layout:
A
-- include
---- foo.h
-- src
---- foo.cpp
B
-- include
---- foo.h
-- src
---- foo.cpp
If you want to support these, you need a way to tell the Swap-feature about your directory layout (some additional configuration data in the project file, maybe). One *could* try to derive an algorithm instead for guessing the right file, but to me this sounds just lke asking for trouble.
Navigation
[0] Message Index
[#] Next page
Go to full version