Bryan Peeters
Bryan Peeters

Reputation: 161

Eclipse CDT with MinGW displays warnings as errors

I have a little problem.

I just installed Eclipse CDT and created a C project using MinGW and all my simple warnings (like "unused variable" etc) are shown as errors.

The program build fine and I can run it, but all these errors are annoying.

I already checked the compiler settings and "Warnings as errors (-Werror)" is unchecked.

What do i do?

Upvotes: 0

Views: 1281

Answers (2)

Sekkuar
Sekkuar

Reputation: 386

In my case, the problem was caused because the compiler/builder's message was in a different language than Eclipse.

Thus, Eclipse could not identify them as Warnings and thought they were Errors instead.

I solved by making an environment variable to set the compiler to the right language,
Thanks to this question

As the messages were sent on the right language, Eclipse changed the markers to warnings and compiled without any error messages.

Upvotes: 2

Alexander Shukaev
Alexander Shukaev

Reputation: 17021

If -Werror would be checked, the build would fail. By the way you should definitely check it so that it enforces you to take care of all the warnings right from the beginning.

You can suppress some warnings (but not all), with special options to GCC (MinGW). You can see which options are needed to suppress this or that warning in the end of the warning itself.

Nevertheless, I strongly recommend against it. It's rather better to resolve all the warnings right from the beginning. Strive to design your projects in the way that they are able to be built with -pedantic -Wall -Wextra -Werror options. There are 3 main benefits of this approach:

  • Your code would be nearly bulletproof;
  • Your code would conform to the standard closely;
  • Your code would be more portable across different compilers (as some of them tend to treat some warnings as errors by default).

Remember, leaving the annoying warning flood is a bad habit, and you should definitely get rid of it right from the start.

Upvotes: 0

Related Questions