[poppler] [PATCH] Simplify the GCC compiler flags/warnings

Hib Eris hib at hiberis.nl
Sat Mar 12 10:48:26 PST 2011


Hi again,

> On Sat, Mar 12, 2011 at 5:46 PM, Pino Toscano <pino at kde.org> wrote:
>> Hi,
>>
>> currently we have (in both the build systems, of course) the option to
>> enable the compiler warnings, with the following values:
>> - no: no CXXFLAGS added
>> - yes (the default): some CXXFLAGS warnings added
>> - kde: more CXXFLAGS added
>>
>> I've done the following patch to simplify the situation a bit, making
>> the warning option (--enable-compile-warnings for autotools,
>> ENABLE_COMPILE_WARNINGS for cmake) a simple yes/no option:
>> - no (the default): the current "yes" CXXFLAGS
>> - yes: all the "no" CXXFLAGS plus the other current "kde" ones
>>
>> The rationale is the following:
>> - compiling without warnings is just a no-no, could hide really huge
>> mistakes
>> - we should put as much useful warnings as possible being used
>> unconditionally (eg take an useful cxxflag, make sure poppler is clean
>> with it, add it to the base ones)
>> - it does not make any sense to enable "kde" warnings: those are
>> useful... because of themselves, not because they are "used by kde"
>>
>> Thoughts? May I commit it?


Two more remarks:

+if test "x$GCC" == xyes; then
+  extra_cxxflags="-Wall -Wno-write-strings -Woverloaded-virtual \
+                  -Wnon-virtual-dtor -Wcast-align -fno-exceptions \
+                  -fno-check-new -fno-common"
+  case "$enable_compile_warnings" in
+    yes)
+      extra_cxxflags="$extra_cxxflags \
+                      -D_XOPEN_SOURCE=600 -D_BSD_SOURCE \
+                      -W -Wno-long-long -Wundef -Wconversion -Wpointer-arith \
+                      -Wwrite-strings -Wformat-security \
+                      -Wmissing-format-attribute"
+      ;;
+    esac
+  CXXFLAGS="$extra_cxxflags $CXXFLAGS"
+fi


1. In the 'yes' case, you end up with both  -Wno-write-strings and
-Wwrite-strings, it is at least not obvious which one the compiler
will pick.
2. The '-W' option could (and in my opinion should) be replaced by
'-Wextra', see  [1].


[1] http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html


More information about the poppler mailing list