[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 1372a42 6/7: Use '-isystem' to suppress warni
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 1372a42 6/7: Use '-isystem' to suppress warnings in third-party headers |
Date: |
Sun, 7 Jun 2020 18:03:29 -0400 (EDT) |
branch: master
commit 1372a42340285f6f3604db30a371142b54261991
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Use '-isystem' to suppress warnings in third-party headers
Some third-party headers elicit warnings, which '-Werror' turns into
errors. There are several ways to avoid that:
(1) Use pragmata to suppress the warnings before including such headers,
and "pop" their suppression right after including them. That doesn't
suppress warnings stemming from macros in those headers. In theory,
each such macro expansion could be surrounded by pragmata, but that's
tedious and ugly.
(2) Same, but don't "pop". Then the warnings remain suppressed for lmi
code that follows, so defects are hidden.
(3) Include such headers with '-isystem', which yields the behavior
described here:
https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html
| All warnings, other than those generated by ‘#warning’ [...],
| are suppressed while GCC is processing a system header.
| Macros defined in a system header are immune to a few warnings
| wherever they are expanded.
Of those options, (1) gives false positives, (2) gives false negatives,
and (3) seems workable.
---
workhorse.make | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/workhorse.make b/workhorse.make
index 8ed48d9..8a73534 100644
--- a/workhorse.make
+++ b/workhorse.make
@@ -295,10 +295,12 @@ wx_config_check:
# http://lists.gnu.org/archive/html/lmi/2006-10/msg00046.html
# for some discussion.
-all_include_directories := \
+lmi_include_directories := \
$(srcdir) \
$(srcdir)/tools/pete-2.1.1 \
$(overriding_include_directories) \
+
+sys_include_directories := \
$(compiler_include_directory) \
$(wx_include_paths) \
/opt/lmi/third_party/include \
@@ -855,7 +857,8 @@ endif
# before or after '=' is an error.
REQUIRED_CPPFLAGS = \
- $(addprefix -I , $(all_include_directories)) \
+ $(addprefix -I , $(lmi_include_directories)) \
+ $(addprefix -isystem , $(sys_include_directories)) \
$(lmi_wx_new_so_attributes) \
$(actually_used_lmi_so_attributes) \
$(platform_defines) \
@@ -924,19 +927,13 @@ REQUIRED_LDFLAGS = \
$(REQUIRED_LIBS) \
# The '--use-temp-file' windres option seems to be often helpful and
-# never harmful. The $(subst) workaround for '-I' isn't needed with
-# GNU windres 2.15.91 20040904
-# and later versions, but is needed with
-# GNU windres 2.13.90 20030111
-# and earlier versions. The $(subst) workaround for '-mno-cygwin' is
-# needed as long as
-# - that option is included in $(ALL_CPPFLAGS), as it apparently
-# should be because it affects the preprocessor; and
-# - $(ALL_CPPFLAGS) is passed to 'windres', which seems common; and
-# - 'windres' doesn't gracefully ignore that option.
+# never harmful.
+#
+# As seems customary, $(ALL_CPPFLAGS) is passed to 'windres', which
+# doesn't recognize '-isystem'--hence the $(subst) workaround.
REQUIRED_RCFLAGS = \
- $(subst -mno-cygwin,,$(subst -I,--include-dir ,$(ALL_CPPFLAGS))) \
+ $(subst -isystem,--include-dir,$(ALL_CPPFLAGS)) \
--use-temp-file \
# To create msw import libraries, use '-Wl,--out-implib,$@.a'. There
@@ -1617,7 +1614,8 @@ show_flags:
@printf 'ALL_LDFLAGS = "%s"\n' "$(ALL_LDFLAGS)"
@printf 'ALL_RCFLAGS = "%s"\n' "$(ALL_RCFLAGS)"
@printf 'srcdir = "%s"\n' "$(srcdir)"
- @printf 'all_include_directories = "%s"\n' "$(all_include_directories)"
+ @printf 'lmi_include_directories = "%s"\n' "$(lmi_include_directories)"
+ @printf 'sys_include_directories = "%s"\n' "$(sys_include_directories)"
@printf 'all_source_directories = "%s"\n' "$(all_source_directories)"
@printf 'wx_include_paths = "%s"\n' "$(wx_include_paths)"
@printf 'wx_libraries = "%s"\n' "$(wx_libraries)"
- [lmi-commits] [lmi] master updated (f3ad703 -> 47ba720), Greg Chicares, 2020/06/07
- [lmi-commits] [lmi] master 47ba720 7/7: Handle a new warning differently, Greg Chicares, 2020/06/07
- [lmi-commits] [lmi] master e66446d 4/7: nullptr, Greg Chicares, 2020/06/07
- [lmi-commits] [lmi] master ea1a8e0 1/7: Represent null pointer as 'nullptr' rather than '0', Greg Chicares, 2020/06/07
- [lmi-commits] [lmi] master 576993a 3/7: Catch even pointers by reference, Greg Chicares, 2020/06/07
- [lmi-commits] [lmi] master 4cdc992 5/7: Use 'override' where appropriate, Greg Chicares, 2020/06/07
- [lmi-commits] [lmi] master fe481a9 2/7: Remove superfluous semicolon, Greg Chicares, 2020/06/07
- [lmi-commits] [lmi] master 1372a42 6/7: Use '-isystem' to suppress warnings in third-party headers,
Greg Chicares <=