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

Bug 331728

Summary: Feature Request: Add -Wextra in addition to -Wall in C/C++'s default project settings
Product: [Tools] CDT Reporter: Jeffrey Walton <noloader>
Component: cdt-buildAssignee: Andrew Gvozdev <angvoz.dev>
Status: RESOLVED DUPLICATE QA Contact: Andrew Gvozdev <angvoz.dev>
Severity: enhancement    
Priority: P3 CC: cdtdoug, obusatto, remy.suen
Version: 7.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Patch for -Wextra and -Wno-unused-parameter (1 of 2)
none
Patch for -Wextra and -Wno-unused-parameter (2 of 2)
none
Patch for -Wextra and -Wno-unused-parameter (2 of 2) none

Description Jeffrey Walton CLA 2010-12-02 17:16:16 EST
Build Identifier: 

-Wextra is a switch that alerts programmers to some of the more mundane issues in their code. In addition, the switch is sometimes used in security audits (a clean compile is a quality gate). Many folks are not aware of the warning switch. Consequently, many programmers are not aware of minor issues in their code.

The -Wextra switch can create a lot of additional noise in C++ projects, especially if many interfaces are present. To quiet the noise, one generally uses -Wno-unused-parameter

It would be great if Eclipse considered the following as default warnings on C/C++ projects which use GCC toolschain:

    -Wall -Wextra -Wno-unused-parameter

Reproducible: Always

Steps to Reproduce:
N/A
Comment 1 Remy Suen CLA 2010-12-02 17:21:24 EST
CDT issues go to CDT.
Comment 2 Andrew Gvozdev CLA 2010-12-02 17:57:02 EST
If anybody is really interested in adding more options, patches are welcome. There is an example of similar change in bug 256763. But for changing the defaults it would take discussing on cdt-dev list.
Comment 3 Jeffrey Walton CLA 2010-12-02 19:01:48 EST
Created attachment 184426 [details]
Patch for -Wextra and -Wno-unused-parameter (1 of 2)
Comment 4 Jeffrey Walton CLA 2010-12-02 19:02:23 EST
Created attachment 184427 [details]
Patch for -Wextra and -Wno-unused-parameter (2 of 2)
Comment 5 Jeffrey Walton CLA 2010-12-02 19:04:08 EST
> If anybody is really interested in adding more options, patches are welcome.
As requested. Options are off by default.

As the options can enhance code quality, I would strongly encourage the development team to debate their inclusion as default values.
Comment 6 Jeffrey Walton CLA 2010-12-02 21:37:13 EST
Created attachment 184430 [details]
Patch for -Wextra and -Wno-unused-parameter (2 of 2)

Updated.... original was borked by putting GDB extensions (-ggdb) under <optionCategory> node rather than <option> node.
Comment 7 Andrew Gvozdev CLA 2010-12-04 09:08:06 EST
Thanks for the patch. Here are some comments:

- You should make changes in necessary files in the project and make patch via Team->Create Patch context menu. No need to rename files. The patch should be from workspace root. That makes it easier for both contributor and committer. See http://wiki.eclipse.org/CDT/contributing for what committers expect in a patch.
- I see new warnings are added for C compiler but not for C++.
- The strings like "%Option.Posix.Warn.ExtraWarn" should be added in plugin.properties with user friendly description similarly to others. Now I just see text "%Option..." in UI.
Comment 8 Otavio Pontes CLA 2011-12-02 12:00:27 EST
I created a patch adding -Wextra and -Wconversion in bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=266305
I'm commenting here because it is related to this one.
Comment 9 Andrew Gvozdev CLA 2011-12-23 16:14:17 EST
-Wextra added to the list in bug 365461. It won't be a default as mentioned.

*** This bug has been marked as a duplicate of bug 365461 ***