2024-08-27 04:54 AM - edited 2024-08-27 04:55 AM
I am trying to enable a warning/error for magic numbers in code analysis. But after I build the project I get no warnnings/errors regarding the magic numbers even tough I have a lot of magic numbers troughout the project.
How do i enable code anaysis?
Solved! Go to Solution.
2024-08-27 07:02 AM
See how include errors are listed in your Problems tab? The static analyzer could be seeing those and giving up, despite it building correctly. You may need to resolve those. Rebuilding the index may help, but sometimes the indexer just doesn't do what you want it to. The Eclipse indexer is not the most robust of products. Static indexing for C/C++ in general is quite difficult.
Project -> C/C++ Index -> Rebuild.
2024-08-27 05:32 AM
Code Analysis will show up in the Problems tab. It is done statically--not during compilation, and won't have any output in the Console tab.
2024-08-27 05:48 AM - edited 2024-08-27 05:50 AM
Bellow is a part of my code where I would expect the warning but is not shown:
2024-08-27 06:14 AM
Perhaps an issue with indexing. If you add them in main.c, can it find them? Your project looks to have compilation error (include not found), does it build successfully?
2024-08-27 06:28 AM
Yes, my project does build successfully. I tried to put a magic number in main,c now and it works in main. How do I make it work also in other files?
2024-08-27 07:02 AM
See how include errors are listed in your Problems tab? The static analyzer could be seeing those and giving up, despite it building correctly. You may need to resolve those. Rebuilding the index may help, but sometimes the indexer just doesn't do what you want it to. The Eclipse indexer is not the most robust of products. Static indexing for C/C++ in general is quite difficult.
Project -> C/C++ Index -> Rebuild.