Skip to main content
manto.1
Associate III
August 27, 2024
Solved

Code analysis not working

  • August 27, 2024
  • 3 replies
  • 1612 views

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?

manto1_0-1724759472998.png

 

Best answer by TDK

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.

3 replies

TDK
Super User
August 27, 2024

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.

TDK_0-1724761859151.png

"If you feel a post has answered your question, please click ""Accept as Solution""."
manto.1
manto.1Author
Associate III
August 27, 2024

Bellow is a part of my code where I would expect the warning but is not shown:

manto1_2-1724763050493.png

 

 

 

TDK
Super User
August 27, 2024

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?

"If you feel a post has answered your question, please click ""Accept as Solution""."
manto.1
manto.1Author
Associate III
August 27, 2024

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?

manto1_0-1724765254548.png

 

TDK
TDKBest answer
Super User
August 27, 2024

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.

"If you feel a post has answered your question, please click ""Accept as Solution""."