Zhigang Wang
  • Home
  • Blog
  • Wiki

Using gcc option -Werror

Last modified on 2009-12-01

It's a good practice to make "-Werror" a default option of your program.

"-Werror" will make all warnings into errors. That means you cannot get you program compiled with even warnings.

Take the following code for example:

/* werror.c
 *
 * complile it with:
 *
 * $ gcc -Werror -o werror werror.c 
 *
 */

/* #include  */

int main(int argc, char *argv[])
{
	printf("Hellow world!\n");

	return 0;
}

Compile it with "-Werror" will result a fail unless you uncomment "#include <stdio.h>":

$ gcc -Werror -o werror werror.c 
cc1: warnings being treated as errors
werror.c: In function ‘main’:
werror.c:13: warning: incompatible implicit declaration of built-in function ‘printf’
 

Categories

  • All contents
  • English contents
  • Chinese contents

Feeds

  • AtomAll contents
  • AtomEnglish contents
  • AtomChinese contents

Tags

  • gtd
  • syslog
  • twiki
  • virtualizaion
  • wiki
  • xen

Copyright © 2012 Zhigang Wang. Some right reserved.

The views expressed on this web site are my own and do not necessarily reflect the views of Oracle.