If you have a unity build setup (where all cpp files are included from one cpp file), the 10x parser needs a little help to parse things correctly.
unity_main.cpp
#define IMPLEMENTATION
#include "header.h"
#include "file1.cpp"
#include "file2.cpp"
#include "file3.cpp"
int main()
{
Implementation();
}
header.h
#define FUNCTION
#ifdef IMPLEMENTATION
// the parser should see this function because IMPLEMENTATION
// is defined in unity_main.cpp before header.h is included
void Implementation()
{
}
#endif
struct TestStruct
{
};
file1.cpp
// FUNCTION should be defined here even though header.h isn't
// included from this file because header.h is included in
// unity_main.cpp before file1.cpp is included
FUNCTION void Test1()
{
TestStruct test;
}
Add the unity build cpp file to the "Prioritise Files" setting in the workspace parser settings.
This makes the parser parse this file first, before any other files are parsed.
Because the header.h include is seen in unity_main.cpp first, it knows that it should be parsed with IMPLEMENTATION defined.
It also means that the cpp files will be parsed with "header.h" included.
If defines are still missing from the parser you can add them explicitly in the Defines workspace setting.
This is equivalent to the define being defined at the top of every file.
If includes are not being picked up you can add the include to the Force Includes workspce setting.
This is equivalent to adding the include at the top of every file.
Here's a simple example workspace that shows how a unity build workspace might be setup
The 10x parser only parses each file once. If a file is included multiple times with different defines set it can only show one version of the file in the editor.
The parser will set any defines that are defined before the file is included but it will use the first include it finds.
For example let's say "header.h" is included from one file without IMPLEMENTATION defined and from another file with it defined, if the parser sees the include without IMPLEMENTATION defined first it will parse header.h as if the define isn't set.
Adding the main unity file to the "Prioritise File" workspace setting works because it makes the parser see the "header.h" include from unity_main.cpp first, which does have the IMPLEMENTATION define set.
Adding the unity main cpp file to the "Prioritise Files" setting also ensures that the cpp files will all be parsed with the header.h include included so you don't need to include header.h in each cpp file.
To keep the parser fast it only traverses forward include dependencies 1 level deep.
So if unity_main.cpp includes file_a.cpp, and file_a.cpp includes file_b.cpp then file_b.cpp won't know that header.h was included in unity_main.cpp.
In this case you should simply add header.h to the Force Includes setting.