X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=/+3ktHSMCQ4FhalSf2M9oaOy9Dlgnq4+IiqUWwXhsVE=; b=dhFm2XAcOBZUv6f4ZtP7Keitwb5LMEzuMgFhxXYUibN+fg8kfXBxZbGaVIXhUus5/k 9OWtH910OqZ0yKJ5uxkdQcxs8kx0M4pc3TQ/OKARC7WnZcbasFYMpJUv/SYGlgtTK+4x 4mh2jTNnLliyKvEKbhjLZpRCp0RqtI8DKvhBDbQBJFl2rKjiFwJskjdVXcQjtNMZb9q5 Pb8dcUvYvYtypTZSxBqAdWolnWJJGHzZ5oQcdIH4m80q297zyRBQzlWE+jTbqe/wkX/x 4BI+WFAjC3YEtRZGHQ58dNJYkeiQ0HjAiGrn71eAdJzEpUx+MkHW0usre1ntcNRvQVp2 /9GA== MIME-Version: 1.0 X-Received: by 10.107.168.25 with SMTP id r25mr923707ioe.126.1445303771029; Mon, 19 Oct 2015 18:16:11 -0700 (PDT) In-Reply-To: References: Date: Mon, 19 Oct 2015 21:16:10 -0400 Message-ID: Subject: Re: [geda-user] please keep master free of all warnings produced by -Wall From: "Bob Paddock (bob DOT paddock AT gmail DOT com) [via geda-user AT delorie DOT com]" To: geda-user AT delorie DOT com Content-Type: text/plain; charset=UTF-8 Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Mon, Oct 19, 2015 at 8:51 PM, Britton Kerin (britton DOT kerin AT gmail DOT com) [via geda-user AT delorie DOT com] wrote: > > as the subject says. This makes it a little easier not to miss warnings > that matter or for people who like to build with -Werror Thank You. Always hate seeing warnings in code. Be aware that -Wall does not actually enable all of the warnings. -Wextra will turn on even more. Then there is is -pedantic. Had this file at hand that is a couple of years old I've added more of the newer warnings in my production code: # Options are ordered in this file from ones that are frequently changed # at the top of the file, to ones that are not changed frequently # during the project at the bottom of this file. # -Werror : Make all warnings into errors. #CFLAGS += -Werror #-Wunreachable-code #Warn if the compiler detects that code will never be executed. [Seems to give bogus results] #CFLAGS += -Wunreachable-code #Warn if an undefined identifier is evaluated in an `#if' directive. CFLAGS += -Wundef # -pedantic : Issue all the mandatory diagnostics listed in the C # standard. Some of them are left out by default, since they trigger frequently # on harmless code. # # -pedantic-errors : Issue all the mandatory diagnostics, and make all # mandatory diagnostics into errors. This includes mandatory diagnostics that # GCC issues without -pedantic but treats as warnings. #CFLAGS += -pedantic # Do not generate tablejump instructions. By default, jump tables can be used # to optimize switch statements. When turned off, sequences of compare # statements are used instead. Jump tables are usually faster to execute on # average, but in particular for switch statements where most of the jumps # would go to the default label, they might waste a bit of flash memory. # CFLAGS += -mno-tablejump # Allocate to an enum type only as many bytes as it needs for the declared # range of possible values. Specifically, the enum type will be equivalent to # the smallest integer type which has enough room. # CFLAGS += -fshort-enums # Dump the internal compilation result called "RTL" into comments in the # generated assembler code. Used for debugging avr-gcc. # CFLAGS += -mrtl # Generate lots of debugging information to stderr. #CFLAGS += -mdeb #-Wchar-subscripts #Warn if an array subscript has type char. This is a common cause of error, as programmers often forget that this type is signed on some machines. This warning is enabled by -Wall. # #-Wcomment #Warn whenever a comment-start sequence `/*' appears in a `/*' comment, or whenever a Backslash-Newline appears in a `//' comment. This warning is enabled by -Wall. # #-Wfatal-errors #This option causes the compiler to abort compilation on the first error occurred rather than trying to keep going and printing further error messages. # #-Wformat #Check calls to printf and scanf, etc., to make sure that the arguments supplied have types appropriate to the format string specified, and that the conversions specified in the format string make sense. # #-Winit-self (C, C++, Objective-C and Objective-C++ only) #Warn about uninitialized variables which are initialized with themselves. Note this option can only be used with the -Wuninitialized option, which in turn only works with -O1 and above. # #-Wimplicit-int #Warn when a declaration does not specify a type. This warning is enabled by -Wall. # #-Wimplicit-function-declaration #-Werror-implicit-function-declaration #Give a warning (or error) whenever a function is used before being declared. The form -Wno-error-implicit-function-declaration is not supported. This warning is enabled by -Wall (as a warning, not an error). # #-Wimplicit #Same as -Wimplicit-int and -Wimplicit-function-declaration. This warning is enabled by -Wall. # #-Wmain #Warn if the type of `main' is suspicious. `main' should be a function with external linkage, returning int, taking either zero arguments, two, or three arguments of appropriate types. This warning is enabled by -Wall. # #-Wmissing-braces #Warn if an aggregate or union initializer is not fully bracketed. In the following example, the initializer for `a' is not fully bracketed, but that for `b' is fully bracketed. # # int a[2][2] = { 0, 1, 2, 3 }; # int b[2][2] = { { 0, 1 }, { 2, 3 } }; # #This warning is enabled by -Wall. # #-Wmissing-include-dirs (C, C++, Objective-C and Objective-C++ only) #Warn if a user-supplied include directory does not exist. [Can cause vary LONG compile times with AVR if missing directory in the path!] # # #-Wparentheses #Warn if parentheses are omitted in certain contexts, such as when there is an assignment in a context where a truth value is expected, or when operators are nested whose precedence people often get confused about. # #This warning is enabled by -Wall. # #-Wsequence-point #Warn about code that may have undefined semantics because of violations of sequence point rules in the C standard. # #This warning is enabled by -Wall. # #-Wreturn-type #Warn whenever a function is defined with a return-type that defaults to int. Also warn about any return statement with no return-value in a function whose return-type is not void. # #This warning is enabled by -Wall. # #-Wswitch #Warn whenever a switch statement has an index of enumerated type and lacks a case for one or more of the named codes of that enumeration. (The presence of a default label prevents this warning.) case labels outside the enumeration range also provoke warnings when this option is used. This warning is enabled by -Wall. # #-Wswitch-default #Warn whenever a switch statement does not have a default case. # #-Wswitch-enum #Warn whenever a switch statement has an index of enumerated type and lacks a case for one or more of the named codes of that enumeration. case labels outside the enumeration range also provoke warnings when this option is used. # #-Wtrigraphs #Warn if any trigraphs are encountered that might change the meaning of the program (trigraphs within comments are not warned about). This warning is enabled by -Wall. # #-Wunused-function #Warn whenever a static function is declared but not defined or a non-inline static function is unused. This warning is enabled by -Wall. # #-Wunused-label #Warn whenever a label is declared but not used. This warning is enabled by -Wall. # #-Wunused-parameter #Warn whenever a function parameter is unused aside from its declaration. # #-Wunused-variable #Warn whenever a local variable or non-constant static variable is unused aside from its declaration This warning is enabled by -Wall. # #-Wunused-value #Warn whenever a statement computes a result that is explicitly not used. This warning is enabled by -Wall. # #To suppress this warning cast the expression to `void'. # #-Wunused #All the above -Wunused options combined. # #-Wuninitialized #Warn if an automatic variable is used without first being initialized or if a variable may be clobbered by a setjmp call. # #This warning is enabled by -Wall. # #-Wstring-literal-comparison #Warn about suspicious comparisons to string literal constants. In C, direct comparisons against the memory address of a string literal, such as if (x == "abc"), typically indicate a programmer error, and even when intentional, result in unspecified behavior and are not portable. # #-Wall # All of the above `-W' options combined. This enables all the warnings about # constructions that some users consider questionable, and that are easy to # avoid (or modify to prevent the warning), even in conjunction with macros. # This also enables some language-specific warnings described in C++ Dialect # Options and Objective-C and Objective-C++ Dialect Options. # # # # #-Wextra #-Wfloat-equal #Warn if floating point values are used in equality comparisons. # #-Wtraditional (C only) #Warn about certain constructs that behave differently in traditional and ISO C. Also warn about ISO C constructs that have no traditional C equivalent, and/or problematic constructs which should be avoided. # #-Wdeclaration-after-statement (C only) #Warn when a declaration is found after a statement in a block # # #-Wshadow #Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed. # # #-Wunsafe-loop-optimizations #Warn if the loop cannot be optimized because the compiler could not assume anything on the bounds of the loop indices. # # #-Wpointer-arith #Warn about anything that depends on the 'size of' a function type or of void. GNU C assigns these types a size of 1, for convenience in calculations with void * pointers and pointers to functions. # #-Wbad-function-cast (C only) #Warn whenever a function call is cast to a non-matching type. For example, warn if int malloc() is cast to anything *. # #-Wcast-qual #Warn whenever a pointer is cast so as to remove a type qualifier from the target type. For example, warn if a const char * is cast to an ordinary char *. # #-Wcast-align #Warn whenever a pointer is cast such that the required alignment of the target is increased. For example, warn if a char * is cast to an int * on machines where integers can only be accessed at two- or four-byte boundaries. # #-Wwrite-strings #When compiling C, give string constants the type const char[length] so that copying the address of one into a non-const char * pointer will get a warning; when compiling C++, warn about the deprecated conversion from string constants to char *. These warnings will help you find at compile time code that can try to write into a string constant, but only if you have been very careful about using const in declarations and prototypes. Otherwise, it will just be a nuisance; this is why we did not make -Wall request these warnings. # #-Wconversion #Warn if a prototype causes a type conversion that is different from what would happen to the same argument in the absence of a prototype. This includes conversions of fixed point to floating and vice versa, and conversions changing the width or signedness of a fixed point argument except when the same as the default promotion. # # #-Wsign-compare #Warn when a comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned. This warning is also enabled by -Wextra; to get the other warnings of -Wextra without this warning, use `-Wextra -Wno-sign-compare'. # # #-Waggregate-return #Warn if any functions that return structures or unions are defined or called. (In languages where you can return an array, this also elicits a warning.) # # #-Wstrict-prototypes (C only) #Warn if a function is declared or defined without specifying the argument types. (An old-style function definition is permitted without a warning if preceded by a declaration which specifies the argument types.) # #-Wold-style-definition (C only) #Warn if an old-style function definition is used. A warning is given even if there is a previous prototype. # #-Wmissing-prototypes (C only) #Warn if a global function is defined without a previous prototype declaration. This warning is issued even if the definition itself provides a prototype. The aim is to detect global functions that fail to be declared in header files. # #-Wmissing-declarations (C only) #Warn if a global function is defined without a previous declaration. Do so even if the definition itself provides a prototype. Use this option to detect global functions that are not declared in header files. # #-Wmissing-field-initializers #Warn if a structure's initializer has some fields missing. # #-Wmissing-noreturn #Warn about functions which might be candidates for attribute noreturn. Note these are only possible candidates, not absolute ones. Care should be taken to manually verify functions actually do not ever return before adding the noreturn attribute, otherwise subtle code generation bugs could be introduced. You will not get a warning for main in hosted C environments. # #-Wmissing-format-attribute #Warn about function pointers which might be candidates for format attributes. Note these are only possible candidates, not absolute ones. # #-Wpacked #Warn if a structure is given the packed attribute, but the packed attribute has no effect on the layout or size of the structure. # #-Wpadded #Warn if padding is included in a structure, either to align an element of the structure or to align the whole structure. Sometimes when this happens it is possible to rearrange the fields of the structure to reduce the padding and so make the structure smaller. # #-Wredundant-decls #Warn if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changes nothing. # #-Wnested-externs (C only) #Warn if an extern declaration is encountered within a function. # #-Wunreachable-code #Warn if the compiler detects that code will never be executed. # #-Winline #Warn if a function can not be inlined and it was declared as inline. Even with this option, the compiler will not warn about failures to inline functions declared in system headers. # #-Winvalid-pch #Warn if a precompiled header (see Precompiled Headers) is found in the search path but can't be used. # #-Wvolatile-register-var #Warn if a register variable is declared volatile. The volatile modifier does not inhibit all optimizations that may eliminate reads and/or writes to register variables. # #-Wdisabled-optimization #Warn if a requested optimization pass is disabled. This warning does not generally indicate that there is anything wrong with your code; it merely indicates that GCC's optimizers were unable to handle the code effectively. Often, the problem is that your code is too big or too complex; GCC will refuse to optimize programs when the optimization itself is likely to take inordinate amounts of time. # #-Wstack-protector #This option is only active when -fstack-protector is active. It warns about functions that will not be protected against stack smashing. -- http://blog.softwaresafety.net/ http://www.designer-iii.com/ http://www.wearablesmartsensors.com/