Changes between Version 10 and Version 11 of Guidelines/WarningsGuidelines
- Timestamp:
- Jan 11, 2011, 2:39:00 AM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Guidelines/WarningsGuidelines
v10 v11 304 304 305 305 ==== Turning off warnings locally ==== 306 So. Suppose you are getting a warning and have checked the code and are '''sure''' that it's a spurious warning. There's nothing wrong. '''If''' the warning is controllable via a command line -W option, then you can (if you have GCC version '''4.2 ''' or newer) turn it off temporarily. First you need to find out what the option might be, then if it exists turn it off via a pragma. How you do this varies a bit with GCC version.306 So. Suppose you are getting a warning and have checked the code and are '''sure''' that it's a spurious warning. There's nothing wrong. '''If''' the warning is controllable via a command line -W option, then you can (if you have GCC version '''4.2.4''' or newer) turn it off temporarily. First you need to find out what the option might be, then if it exists turn it off via a pragma. How you do this varies a bit with GCC version. 307 307 308 308 -fdiagnostics-show-option:: 309 In GCC, for versions 4. 3and higher, this option instructs the diagnostic machinery to add text to each diagnostic emitted, which indicates which command line option directly controls that diagnostic, when such an option is known to the diagnostic machinery.309 In GCC, for versions 4.2.4 and higher, this option instructs the diagnostic machinery to add text to each diagnostic emitted, which indicates which command line option directly controls that diagnostic, when such an option is known to the diagnostic machinery. 310 310 #pragma GCC diagnostic push:: 311 311 Available since GCC version 4.6, this pragma lets you remember diagnostic options in place at a particular time. This pragma can occur on any line of a file. … … 313 313 Available since GCC version 4.6, this pragma lets you restore diagnostic options that were remembered by a diagnostic push. This pragma can occur on any line of a file. 314 314 #pragma GCC diagnostic [warning|error|ignored] OPTION:: 315 After GCC version 4.1and before GCC version 4.6 this could be specified at file scope outside of any functions, classes, unions, structs, or methods, to change the behavior when a particular class of error was seen. For GCC version 4.6 and later, it can be put in any line of a file, and affects from that position forward. For any supported version, it only works with warnings that have explicit -W arguments, use -fdiagnostic-show-option to find out which one to use. An example: #pragma GCC diagnostic ignored "-Wdeprecated-declarations"316 317 So prior to 4.6just put near the top of the file something like:315 From GCC version 4.2.4 and before GCC version 4.6 this could be specified at file scope outside of any functions, classes, unions, structs, or methods, to change the behavior when a particular class of error was seen. For GCC version 4.6 and later, it can be put in any line of a file, and affects from that position forward. For any supported version, it only works with warnings that have explicit -W arguments, use -fdiagnostic-show-option to find out which one to use. An example: #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 316 317 So starting from 4.2.4 but before 4.6, just put near the top of the file something like: 318 318 319 319 #pragma GCC diagnostic ignored "-Wdeprecated-declarations