cancel
Showing results for 
Search instead for 
Did you mean: 

Code analysis not working

manto.1
Senior

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

 

1 ACCEPTED SOLUTION

Accepted Solutions

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".

View solution in original post

5 REPLIES 5
TDK
Guru

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".

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

manto1_2-1724763050493.png

 

 

 

TDK
Guru

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
Senior

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

 

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".