0

Disclaimer: Nothing to do with this question

Hello there,

I'm having an issue in Eclipse CDT. I can't get to have my editor update errors & warnings as I edit my .c source files.

In order to get errors to show up, I need to build manually all the time. Am I missing something ?

I have tried all the options at my disposal within the CDT config panel.

Thanks in advance.

EDIT:

In foo.c:

int main() {
    return 1 << 40 - 1;
}

Using gccto compile I have:

foo.c: In function ‘main’:
foo.c:2:11: warning: left shift count >= width of type [-Wshift-count-overflow]
 return 1 << 40 - 1;

Which appears correctly after I build the project in eclipse, but doesn't show otherwise.

TDk
  • 1,019
  • 6
  • 18
  • Is _Project > Build Automatically_ enabled? How is your project configured? An example and a screenshot would be helpful. – howlger Oct 10 '17 at 11:27
  • Unfortunately the Build automatically option is activated... I have edited my post with an example. – TDk Oct 10 '17 at 12:01
  • Also, my project is Makefile based. – TDk Oct 10 '17 at 12:03
  • Without running GCC, these kind of errors that require a deep semantic analysis with consideration of the compiler settings cannot be detected. On save, the file will only be parsed and syntax errors will be displayed, e. g. if you write `returns` instead of `return`. – howlger Oct 10 '17 at 12:10
  • Well, couldn't Eclipse use a language server to do that ? or just deep analyze the code ? It seems to me this is kind of the base of an IDE ... – TDk Oct 10 '17 at 12:18
  • Eclipse does perform a deep analysis of the code itself, but there are many warnings missing in its analysis compared to a compiler's and this is one of them. As for using a language server... that's a pretty new technology (~1 year old) compared to Eclipse CDT (10+ years old). There are plans to integrate language server support into CDT but they are at an early stage. – HighCommander4 Oct 10 '17 at 15:43

1 Answers1

2

Without running GCC, these kind of errors (which require a deep semantic analysis with consideration of the compiler settings) cannot be detected.

By default, on save, the file will only be scanned/parsed for indexing (used for navigation and C/C++ Search) and for detecting syntax errors like returns instead of return.

To run GCC on save: in Project > Properties: C/C++ Build, in the tab Behavior check the checkbox Build on resource save (Auto build)

howlger
  • 31,050
  • 11
  • 59
  • 99
  • Unfortunately there is no such option in my project settings under C/C++ build. And searching for "save" or "auto" in the search bar doesn't give any result – TDk Oct 10 '17 at 12:38