It looks like include files are searched in paths gathered from all build targets instead of only current one or targets available for current platform.
I have my own windows.h with some stubs inside which is used for Linux targets only but this file is parsed on Windows as well shadowing the real windows.h.
Do you mean that you have a local
windows.h
and a globalwindows.h
, but the local header file is always searched by the CC's parser?I just looked at the parser's source code, and I found one function:
My first reading of the code is that It looks like the global file is always used.
Yes, the code looks like that, but still when I have "#include <windows.h>" in my *.cpp files and following piece in my cbp:
"Find declaration of" menu item used send me to the file windows.h placed in ../Compat/Windows and give error "Symbol not found" for symbols that are not defined there.
I've noticed that the problem happens if this project is active by default in workspace. If I load the workspace when default active project is one that has no references to Compat dir - everything works well and the menu item show me BOTH declarations from system windows.h and from my own. So the bug must be not in this piece of code but somewhere in include dirs list gathering: starting project's search path is getting priority over system default.
Last edit: Dimitry Sibiryakov 2021-05-02
So, it looks like some times it works, and sometimes it doesn't.
If you have two C::B projects in a workspace, then there are some parser options. One option is that a parser will parser all files in a workspace, and put all the symbols/tokens in a single TokenTree. Another option is that each projects will have a separate TokenTree.
I think a minimal sample project/workspace is needed to debug this issue. For example, there are two projects (a.cbp and b.cbp)
In a.cbp, the "../Compat/Windows" may contains a customized "windows.h", and this header file only contains a some unique class definition, such as :
Then put some code statement like in a.cpp inside a.cbp:
In a.cpp file inside a.cbp, and use the mouse context menu to find the AAAAAA, this will jump to local windows.h.
Maybe, in another b.cbp project, just add some cpp code like:
This should got error, because the system's windows.h don't have AAAAAA defined.
Is this good sample workspace? Or you can help to create one? Thanks.
I did a simple test, if I put a local "windows.h", and I see it will be searched first.
I looked at the source code, and I see that the include search path defined in cbp file is first added in the Parser object,
So, for example, if I have a cbp file located in "d:/abc/", this path will be put first in the header file search dirs, after that, the compiler's default search path such as mingw gcc's search paths will be added.
I'm sorry, at least a half of this ticket is wrong. Attached sample project shows wrong declaration but only if currently inactive target is enabled for current platform. I.e. if selected build target is WinRelease then search path from LinRelease is used by parser. But if LinRelease target is disabled for Windows then it is ignored by parser as expected.
It would be better if projects were reparsed when build target is changed taking into account only settings from selected target but current behavior is not a bug, just a missed feature.
Last edit: Dimitry Sibiryakov 2021-05-03