Le 21/02/2014 03:16, Lex Trotman a écrit :
> [...]
> 
> Well, the same as for code written by humans, the C compiler warning
> is telling us something *might* be wrong with the code.  The Vala
> compiler may have bugs, so such things need checking the same as
> manual code, to avoid possible UB.  If, as in these cases, it seems to
> be ok, then its just noise, but unless you check you don't know.
> 
>> IMO, we should just disable warnings on Vala's generated code altogether and
>> rely only on the Vala warnings. Anything else is a Vala bug and not our
>> problem. I would've done this long ago but I'm not sure how to
>> properly/portably disable warnings for a particular target in Autotools.
> 
> Whilst I don't agree totally (see above), thats probably better, but I
> dunno how to do it either, Autotools experts please assist.

Per-target flags are easy, they are target_CFLAGS, target_LDFLAGS and so
on.  Thought, note this is per *target*, so if you mix C and Vala in the
same target, obviously those flags will apply to all use of the C
compiler, linker, etc. for this target.

To disable warnings, there are 2 solutions:

1) don't add the warning flags;
2) add flags to disable the warnings.

Solution 1) seems reasonable, but it won't be able to remove user-set
warnings in CFLAGS -- and we just *cannot* ignore user CFLAGS, there may
be include paths and stuff.

Also, with the current setup it seems easier to just add flags than
remove existing ones, because currently they are added automatically in
vars.build.mk.  Adding them conditionally may be tricky, because AFAIK
make conditionals are unportable (e.g. BSD make and GNU make aren't
compatible).  Maybe Loong Jin knows better?

Even if we go with solution 2), we have 2 ways to apply it:  overriding
some user warnings flags or not.  Overriding user warning flags would
allow for users to have stricter warnings for real C code while not
being flooded by Vela-generated ones, but again, it may be considered
harmful.  OTOH, if we don't override it basically only benefit people
not having a custom CFLAGS defined (even if it is set to the same value
as our default).

Attached are 2 examples of solution 2), not overriding and overriding.
Just toy patches for now, but it should work.

> 
> [...]
>>
>> The GTK2 Vala binding is deprecated, same as the GTK2 C API/library. There
>> is a compiler flag for Valac to make it disable the deprecation warnings, if
>> that is desirable.

Is there really a flag to only disable deprecated warnings?  IIRC there
is only --disable-warnings, and IIUC it removes everything not an error?

Cheers,
Colomban
diff --git a/build/cflags.m4 b/build/cflags.m4
index 01427d8..f8cb42e 100644
--- a/build/cflags.m4
+++ b/build/cflags.m4
@@ -45,3 +45,34 @@ AC_DEFUN([GP_CHECK_CFLAGS],
     GP_STATUS_BUILD_FEATURE_ADD([Extra C compiler warnings],
                                 [$enable_extra_c_warnings])
 ])
+
+dnl GP_CHECK_VALA_CFLAGS
+dnl Checks for default Geany-Plugins CFLAGS used for Vala targets,
+dnl and defines GP_VALA_CFLAGS
+AC_DEFUN([GP_CHECK_VALA_CFLAGS],
+[
+    AC_ARG_ENABLE([reduced-vala-c-warnings],
+                  AS_HELP_STRING([--disable-reduced-vala-c-warnings],
+                      [Disable reduced C Compiler warnings for Vala-generated code]),
+                  [enable_reduced_vala_c_warnings=$enableval],
+                  [enable_reduced_vala_c_warnings=yes])
+
+    GP_VALA_CFLAGS=
+    AS_IF([test "x$enable_reduced_vala_c_warnings" != xno],
+    [
+        enable_reduced_vala_c_warnings=yes
+        for flag in -Wno-conversion \
+                    -Wno-pedantic \
+                    -Wno-redundant-decls \
+                    -Wno-sign-compare \
+                    -Wno-unused \
+                    -Wno-unused-but-set-parameter \
+                    -Wno-unused-but-set-variable \
+                    -Wno-unused-parameter \
+                    -Wno-unused-variable
+        do
+            _GP_CHECK_CFLAG_([$flag], [GP_VALA_CFLAGS="${GP_VALA_CFLAGS} $flag"])
+        done
+    ])
+    AC_SUBST([GP_VALA_CFLAGS])
+])
diff --git a/configure.ac b/configure.ac
index 703a853..a913e96 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,7 @@ GP_CHECK_UNITTESTS(0.9.4)
 GP_CHECK_GTK_VERSION
 GP_CHECK_CPPCHECK
 GP_CHECK_CFLAGS
+GP_CHECK_VALA_CFLAGS
 
 dnl plugin checks
 GP_CHECK_ADDONS
diff --git a/multiterm/src/Makefile.am b/multiterm/src/Makefile.am
index 70447ff..50c9aa3 100644
--- a/multiterm/src/Makefile.am
+++ b/multiterm/src/Makefile.am
@@ -3,6 +3,9 @@ include $(top_srcdir)/build/vars.docs.mk
 
 plugin = multiterm
 
+CFLAGS ?=
+CFLAGS += $(GP_VALA_CFLAGS)
+
 geanyplugins_LTLIBRARIES = multiterm.la
 
 multiterm_la_VALAFLAGS = \
diff --git a/build/cflags.m4 b/build/cflags.m4
index 01427d8..f331115 100644
--- a/build/cflags.m4
+++ b/build/cflags.m4
@@ -45,3 +45,26 @@ AC_DEFUN([GP_CHECK_CFLAGS],
     GP_STATUS_BUILD_FEATURE_ADD([Extra C compiler warnings],
                                 [$enable_extra_c_warnings])
 ])
+
+dnl GP_CHECK_VALA_CFLAGS
+dnl Checks for default Geany-Plugins CFLAGS used for Vala targets,
+dnl and defines GP_VALA_CFLAGS
+AC_DEFUN([GP_CHECK_VALA_CFLAGS],
+[
+    AC_ARG_ENABLE([reduced-vala-c-warnings],
+                  AS_HELP_STRING([--disable-reduced-vala-c-warnings],
+                      [Disable reduced C Compiler warnings for Vala-generated code]),
+                  [enable_reduced_vala_c_warnings=$enableval],
+                  [enable_reduced_vala_c_warnings=yes])
+
+    GP_VALA_CFLAGS=
+    AS_IF([test "x$enable_reduced_vala_c_warnings" != xno],
+    [
+        enable_reduced_vala_c_warnings=yes
+        for flag in -Wno-unused
+        do
+            _GP_CHECK_CFLAG_([$flag], [GP_VALA_CFLAGS="${GP_VALA_CFLAGS} $flag"])
+        done
+    ])
+    AC_SUBST([GP_VALA_CFLAGS])
+])
diff --git a/configure.ac b/configure.ac
index 703a853..a913e96 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,7 @@ GP_CHECK_UNITTESTS(0.9.4)
 GP_CHECK_GTK_VERSION
 GP_CHECK_CPPCHECK
 GP_CHECK_CFLAGS
+GP_CHECK_VALA_CFLAGS
 
 dnl plugin checks
 GP_CHECK_ADDONS
diff --git a/multiterm/src/Makefile.am b/multiterm/src/Makefile.am
index 70447ff..632ffd1 100644
--- a/multiterm/src/Makefile.am
+++ b/multiterm/src/Makefile.am
@@ -25,6 +25,7 @@ multiterm_la_SOURCES = \
 
 multiterm_la_CFLAGS = \
 	$(AM_CFLAGS) \
+	$(GP_VALA_CFLAGS) \
 	$(MULTITERM_CFLAGS)
 
 multiterm_la_LIBADD = \
_______________________________________________
Devel mailing list
Devel@lists.geany.org
https://lists.geany.org/cgi-bin/mailman/listinfo/devel

Reply via email to