Selectively disable GCC warnings for only part of a translation unit

This is possible in GCC since version 4.6, or around June 2010 in the trunk. Here’s an example: #pragma GCC diagnostic push #pragma GCC diagnostic error “-Wuninitialized” foo(a); /* error is given for this one */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored “-Wuninitialized” foo(b); /* no diagnostic for this one */ #pragma GCC … Read more

Custom Compiler Warnings

This is worth a try. You can’t extend Obsolete, because it’s final, but maybe you can create your own attribute, and mark that class as obsolete like this: [Obsolete(“Should be refactored”)] public class MustRefactor: System.Attribute{} Then when you mark your methods with the “MustRefactor” attribute, the compile warnings will show. It generates a compile time … Read more

Multi-character constant warnings

According to the standard (§6.4.4.4/10) The value of an integer character constant containing more than one character (e.g., ‘ab’), […] is implementation-defined. long x = ‘\xde\xad\xbe\xef’; // yes, single quotes This is valid ISO 9899:2011 C. It compiles without warning under gcc with -Wall, and a “multi-character character constant” warning with -pedantic. From Wikipedia: Multi-character … Read more