You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an Embedded C project to be run on a multiple-core hardware platform.
In a single source file (main.c), there are codes for both CPU0 and CPU1. The code of different CPUs is separated by different definitions.
When making the project, code of both CPUs is compiled. Use Bear to generate the compile_commands.json, there are two build commands with different -DCPU_ID of the single main.c. One is for CPU0, and the other is CPU1.
It seems Clangd only use the first -DCPU_ID listed in the compile_commands.json, so only the code of CPU0 is available when reading the source file. If I want to read the code of CPU1, I need to put the build commands of CPU1 at the first place.
Is it any methods to make the codes of both CPUs available at the same time? I understand this requirement maybe not intuitive or logical because the CPU_ID mustn't be two different values at the same time, but it really helps a lot to read the code if it is available. Thanks.
The text was updated successfully, but these errors were encountered:
If we tried to make the compiler process both branches of an #if during a single compilation, it would run into errors in many cases. For example, both branches could define a function with the same name, in which case processing both would lead to a "multiple definitions" error. Or the branch could be placed in the middle of a declaration such that the contents of the two branches in sequence isn't even syntactically valid.
I think the only way to make this work in general would be to have the compiler build two different ASTs (one for each value of CPU_ID), and then teach every editor feature to base its results on multiple ASTs. (For example, for semantic tokens, the tokens from the two ASTs could be merged into a single set of tokens. For go-to-definition, it would be performed on each AST, and results from both would be offered). It's possible in theory, but it would take an enormous amount of work.
I have an Embedded C project to be run on a multiple-core hardware platform.
In a single source file (main.c), there are codes for both CPU0 and CPU1. The code of different CPUs is separated by different definitions.
When making the project, code of both CPUs is compiled. Use Bear to generate the compile_commands.json, there are two build commands with different -DCPU_ID of the single main.c. One is for CPU0, and the other is CPU1.
It seems Clangd only use the first -DCPU_ID listed in the compile_commands.json, so only the code of CPU0 is available when reading the source file. If I want to read the code of CPU1, I need to put the build commands of CPU1 at the first place.
Is it any methods to make the codes of both CPUs available at the same time? I understand this requirement maybe not intuitive or logical because the CPU_ID mustn't be two different values at the same time, but it really helps a lot to read the code if it is available. Thanks.
The text was updated successfully, but these errors were encountered: