Motion - Compile With Developer Flags

Compile With Developer Flags

This topic tries to describes what the flags mean, what to do to avoid compiler warnings for each flag.

From 3.2.2_snap12 a new configure flag --with-developer-flags has been introduced. It is default off and meant to be used only by developers when cleaning up code. We do not want normal users to be troubled with this.

These are the extra flags added:

-Wextra -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long

-- KennethLavrsen - 12 Aug 2005 / 05 Sep 2005


Issue all the warnings demanded by strict ISO C and ISO C++; reject all programs that use forbidden extensions, and some other programs that do not follow ISO C and ISO C++. For ISO C, follows the version of the ISO C standard specified by any -std option used.

Valid ISO C and ISO C++ programs should compile properly with or without this option (though a rare few will require -ansi or a -std option specifying the required version of ISO C). However, without this option, certain GNU extensions and traditional C and C++ features are supported as well. With this option, they are rejected.

-pedantic does not cause warning messages for use of the alternate keywords whose names begin and end with __. Pedantic warnings are also disabled in the expression that follows "__extension__". Where the standard specified with -std represents a GNU extended dialect of C, such as gnu89 or gnu99, there is a corresponding base standard, the version of ISO C on which the GNU extended dialect is based. Warnings from -pedantic are given where they are required by the base standard. (It would not make sense for such warnings to be given only for features not in the specified GNU C dialect, since by definition the GNU dialects of C include all features the compiler supports with the given option, and there would be nothing to warn about.)

For now we do not build with -pedantic since most warnings are related to compatibility with very old compilers and we should be able to use new compiler features. If we can compile Motion with gcc 2.95 or newer I am happy. -- KennethLavrsen - 05 Sep 2005


(This option used to be called -W. The older name is still supported, but the newer name is more descriptive.) Print extra warning messages for these events:

  • A function can return either with or without a value. (Falling off the end of the function body is considered returning without a value.)
  • An expression-statement or the left-hand side of a comma expression contains no side effects. To suppress the warning, cast the unused expression to void. For example, an expression such as x[i,j] will cause a warning, but x[(void)i,j] will not.
  • An unsigned value is compared against zero with < or >=.
  • Storage-class specifiers like "static" are not the first things in a declaration. According to the C Standard, this usage is obsolescent.
  • If -Wall or -Wunused is also specified, warn about unused arguments.
  • A comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned. (But don't warn if -Wno-sign-compare is also specified.)
  • An aggregate has an initializer which does not initialize all members. This warning can be independently controlled by -Wmissing-field-initializers.
  • A function parameter is declared without a type specifier in K&R-style functions: void foo(bar) { }
  • An empty body occurs in an if or else statement.
  • A pointer is compared against integer zero with <, <=, >, or >=.
  • A variable might be changed by longjmp or vfork.
  • Any of several floating-point events that often indicate errors, such as overflow, underflow, loss of precision, etc.


Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed.


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.


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.


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.


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.)


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.


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.


Warn if an "extern" declaration is encountered within a function.


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.

The compiler uses a variety of heuristics to determine whether or not to inline a function. For example, the compiler takes into account the size of the function being inlined and the amount of inlining that has already been done in the current function. Therefore, seemingly insignificant changes in the source program can cause the warnings produced by -Winline to appear or disappear.


Warn if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changes nothing.


Accept long long int.
Topic revision: r3 - 05 Sep 2005, KennethLavrsen
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.