Hi,

This patch will add warning flags.

There are currently 5 warning levels, which defaults to level 3. It gets noisier for higher levels. Level 0 is equivalent to no additional flags. Use "--with-warnings[=n]" to set the levels.

I really wanted -Werror by default, so you can stop to see *all* the warnings, but its too strict for buildbot.

The warning levels can still be fine tuned. If needed, there can also be more warning levels.

Comments?
Index: configure.ac
===================================================================
--- configure.ac        (revision 1170)
+++ configure.ac        (working copy)
@@ -112,6 +112,38 @@
 
 AC_CHECK_HEADER([_mingw_mac.h], [], [AC_MSG_ERROR([Please check if the 
mingw-w64 header set and the build/host option are set properly.])])
 
+#Warnings and errors, default level is 3
+AC_ARG_WITH([warnings],
+            [AS_HELP_STRING([[--with-warnings[=0-5]]], [Set compile time 
warning levels (default is 3)])],
+            [warning_level=$withval],
+            [warning_level=3]
+            )
+
+#Warning level validation
+AS_IF([test "$warning_level" == yes], [warning_level=3], [test 
"$warning_level" == no], [warning_level=0])
+AS_IF([test $warning_level -gt 5 || test $warning_level -lt 0], 
[warning_level=3])
+AC_MSG_CHECKING([for warning levels])
+AC_MSG_RESULT([Level $warning_level])
+
+#Add CPPFLAGS, CFLAGS, CXXFLAGS as appropriate. Level 4 and above is only for 
testing purpose.
+AS_CASE([$warning_level],
+    [0],[],
+    [1],[ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra"
+         ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration"],
+    [2],[ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra -Wformat -Wstrict-aliasing 
-Wsystem-headers -Wshadow -Wmissing-declarations -Wpacked -Wredundant-decls 
-Winline" 
+         ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration"],
+    [3],[ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra -Wformat -Wstrict-aliasing 
-Wsystem-headers -Wshadow -Wmissing-declarations -Wpacked -Wredundant-decls 
-Winline -Wstrict-aliasing=3" 
+         ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration 
-Wmissing-noreturn -Wmissing-prototypes"],
+    [4],[ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra -Wformat -Wstrict-aliasing 
-Wsystem-headers -Wshadow -Wmissing-declarations -Wpacked -Wredundant-decls 
-Winline -Wstrict-aliasing=2 -Werror -pedantic" 
+         ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration 
-Wmissing-noreturn -Wmissing-prototypes"]
+    [5],[ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra -Wformat -Wstrict-aliasing 
-Wsystem-headers -Wshadow -Wmissing-declarations -Wpacked -Wredundant-decls 
-Winline -Wstrict-aliasing=2 -Werror -Wfatal-errors -pedantic -pedantic-errors" 
+         ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration 
-Wmissing-noreturn -Wmissing-prototypes"]
+        )
+
+AC_SUBST(ADD_C_ONLY_WARNING_FLAGS)
+AC_SUBST(ADD_C_CXX_WARNING_FLAGS)
+AC_SUBST(ADD_CXX_ONLY_WARNING_FLAGS)
+
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
 
@@ -125,9 +157,12 @@
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Configuration Options Summary:])
 AC_MSG_NOTICE([])
-AC_MSG_NOTICE([  WinCE runtime.....: $enable_libce])
-AC_MSG_NOTICE([  Win32 runtime.....: $enable_lib32])
-AC_MSG_NOTICE([  Win64 runtime.....: $enable_lib64])
+AC_MSG_NOTICE([  WinCE runtime........: $enable_libce])
+AC_MSG_NOTICE([  Win32 runtime........: $enable_lib32])
+AC_MSG_NOTICE([  Win64 runtime........: $enable_lib64])
+AC_MSG_NOTICE([  C Warning Flags......: $ADD_C_ONLY_WARNING_FLAGS])
+AC_MSG_NOTICE([  C++ Warning Flags....: $ADD_CXX_ONLY_WARNING_FLAGS])
+AC_MSG_NOTICE([  Common Warning Flags.: $ADD_C_CXX_WARNING_FLAGS])
 AC_MSG_NOTICE([])
 
 
Index: Makefile.am
===================================================================
--- Makefile.am (revision 1170)
+++ Makefile.am (working copy)
@@ -22,7 +22,8 @@
 
 
 AM_CPPFLAGS=-D_CRTBLD $(sysincludes)
-AM_CFLAGS=-pipe $(vistasupport) -Wall -Wno-strict-aliasing -std=gnu99
+AM_CFLAGS=-pipe $(vistasupport) -Wall -Wno-strict-aliasing -std=gnu99 
@ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@
+am_cxxfla...@add_cxx_only_warning_flags@ @ADD_CXX_ONLY_WARNING_FLAGS@
 AM_DLLTOOLFLAGS=-k --as=$(AS) --output-lib $@
 DTDEF=$(DLLTOOL) $(AM_DLLTOOLFLAGS) --def
 DTLIB=$(DTDEF) $(top_srcdir)/`echo $@ | $(SED) 's|/lib|/|;s|\.a|.def|'`
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to