Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 363123

Summary: Mark undefined symbols in C editor
Product: [Tools] CDT Reporter: Marko Tomljenovic <marko.tomljenovic>
Component: cdt-codanAssignee: CDT Codan Inbox <cdt-codan-inbox>
Status: RESOLVED INVALID QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: enhancement    
Priority: P3 CC: aleherb+eclipse, cdtdoug, zeratul976
Version: 7.0.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Marko Tomljenovic CLA 2011-11-08 01:56:18 EST
Build Identifier: CDT 7.0.2.201102110609

When editing C files it would be very helpful to see whether a symbol is undefined in the current context.
In my case I have the following code

#if (undefSymbol < 4)
#include "header1.h"
#elif (miscSymbol < 5)
#include "header2.h"
#endif

In this case the first condition resolves to true since the default value of the undefined symbol is 0 and I forgot to defined the symbol. Marking the symbol as undefined would help me a lot finding out those problems where I forgot to define a symbol.

Reproducible: Always

Steps to Reproduce:
See details
Comment 1 Anton Leherbauer CLA 2011-11-10 04:07:15 EST
Sounds like a potential codan feature.
Comment 2 Nathan Ridge CLA 2013-07-17 22:22:28 EDT
Where in the UI should the symbol be marked as undefined?

Note that if you hover over a symbol, if it's defined then a 'Macro expansion' hover will appear with its expansion, and if it's not defined then no hover will appear - that is one way to tell whether a symbol is defined or not.
Comment 3 Marko Tomljenovic CLA 2013-07-18 16:35:38 EDT
I could use the hover but this is cumbersome.
Either a codan check that creates an error marker or a specific "decoration" in the editor would be fine. Both is fine to me.

It just need to be visible in the editor without the user being forced to hover over the symbol or open context menu, ... (do an additional action)
Comment 4 Nathan Ridge CLA 2013-07-18 20:49:48 EDT
I don't think a oodan checker is appropriate here, because undefined symbols in preprocessor statements regularly appear in perfectly valid C++ code.

Would a different syntax coloring for undefined symbols achieve your objective?
Comment 5 Marko Tomljenovic CLA 2013-07-19 02:25:29 EDT
Sure, would be fine for me.
Comment 6 Anton Leherbauer CLA 2013-07-19 02:34:23 EDT
Coloring of unresolved symbols is possible today.
Just enable "Problems" in the Syntax Highlighting preferences.
Comment 7 Marko Tomljenovic CLA 2013-07-19 03:05:02 EDT
Hmm, thank your for the hint.

Never say that entry in the preferences till today.

What other kind of "problems" are then also marked?

Is it documented somewhere so I can read it myself and you can close this issue ;)

Greets Marko
Comment 8 Anton Leherbauer CLA 2013-07-19 03:17:53 EDT
I just noticed that this is about undefined preprocessor symbols.
With "Problems" you can only highlight identifiers which did not resolve _after_ preprocessing. It seems Codan marks those identifiers anyway, so this does not provide additional value.
Comment 9 Marko Tomljenovic CLA 2013-07-19 03:19:29 EDT
But it is definitely what I need.

Thank you.

Next time I will RTFM before I open up an issue.
Comment 10 Nathan Ridge CLA 2013-07-20 02:25:17 EDT
(In reply to comment #9)
> But it is definitely what I need.
> 
> Thank you.
> 
> Next time I will RTFM before I open up an issue.

If you have what you need, please close the bug as 'invalid'. Thanks!
Comment 11 Marko Tomljenovic CLA 2013-07-20 14:09:40 EDT
Issue already fixed by an already existing feature.
But this feature was not known to the creator of the issue.