Control: tags -1 + patch
On Mon, 16 Aug 2021 at 18:42:26 +0300, Adrian Bunk wrote:
> In file included from /usr/include/glib-2.0/glib/gatomic.h:31,
> from /usr/include/glib-2.0/glib/gthread.h:32,
> from /usr/include/glib-2.0/glib/gasyncqueue.h:32,
> from /usr/include/glib-2.0/glib.h:32,
> from /usr/include/glib-2.0/gobject/gbinding.h:28,
> from /usr/include/glib-2.0/glib-object.h:22,
> from /usr/include/libwnck-3.0/libwnck/window.h:33,
> from /usr/include/libwnck-3.0/libwnck/libwnck.h:26,
> from src/ukws_window_box.h:25,
> from src/ukws_indicator.h:24,
> from src/ukws_indicator.cpp:20:
> /usr/include/c++/10/type_traits:56:3: error: template with C linkage
>56 | template
> | ^~~~
> In file included from src/ukws_indicator.h:24,
> from src/ukws_indicator.cpp:20:
> src/ukws_window_box.h:23:1: note: ‘extern "C"’ linkage started here
>23 | extern "C" {
> | ^~
Bugs with this compiler error are caused by a header behaviour change
in GLib 2.68.
In older versions, the GLib headers contained only C code, even when
compiled with a C++ compiler. In GLib 2.68+, if C++ compilation is
detected, the headers make use of C++ features to make macros like
g_object_ref() more type-safe.
There are two ways to resolve the build failure:
1. Move inclusions of system headers outside extern "C" blocks, at least
for well-behaved libraries like GLib and GTK that already include their
own extern "C" guard, either directly or via macros like GLib's own
G_BEGIN_DECLS/G_END_DECLS.
Attached patch Don-t-wrap-C-header-inclusions-in-extern-C.patch
implements this.
2. Target a specific GLib version older than 2.68 by defining the macros
GLIB_VERSION_MIN_REQUIRED and GLIB_VERSION_MAX_ALLOWED (see GLib's
documentation for details). This asks GLib to disable behaviour changes
and deprecation warnings that happened since the target version.
https://github.com/brummer10/gxtuner/pull/21 is an example of this
in a different project, but I don't know how to specify CPPFLAGS
in a qmake project, so I haven't attached a patch implementing this.
Maintainers can choose either or both of those methods. I would personally
recommend doing both.
Thanks,
smcv
From: Simon McVittie
Date: Mon, 16 Aug 2021 18:29:14 +0100
Subject: Don't wrap C header inclusions in extern "C"
The GLib, Gdk-Pixbuf, Wnck and XCB headers all use extern "C"
internally, so it is unnecessary to wrap their inclusion in an
extern "C" block.
A redundant extern "C" block can be harmful, for example if these headers
test for defined(__cplusplus) and, if defined, use C++ features in their
macros. GLib 2.68 started to do this, to make macros like g_object_ref()
type-safe, resulting in compilation failure for C++ projects that
assumed GLib headers would always be pure C.
Bug-Debian: https://bugs.debian.org/992271
---
src/ukws_helper.h| 2 --
src/ukws_window_box.h| 2 --
src/ukws_window_info.h | 2 --
src/ukws_wnck_operator.h | 2 --
src/ukws_workspace_box.h | 2 --
5 files changed, 10 deletions(-)
diff --git a/src/ukws_helper.h b/src/ukws_helper.h
index 610e91c..59806de 100644
--- a/src/ukws_helper.h
+++ b/src/ukws_helper.h
@@ -20,10 +20,8 @@
#ifndef UKWS_HELPER_H
#define UKWS_HELPER_H
-extern "C" {
#include
#include
-}
#include
#include
diff --git a/src/ukws_window_box.h b/src/ukws_window_box.h
index feb6a4b..d16da93 100644
--- a/src/ukws_window_box.h
+++ b/src/ukws_window_box.h
@@ -20,10 +20,8 @@
#ifndef UKWS_WINDOWBOX_H
#define UKWS_WINDOWBOX_H
-extern "C" {
#define WNCK_I_KNOW_THIS_IS_UNSTABLE
#include
-}
#include "ukws_window_extra_label.h"
diff --git a/src/ukws_window_info.h b/src/ukws_window_info.h
index 2c6d4e6..ef590e8 100644
--- a/src/ukws_window_info.h
+++ b/src/ukws_window_info.h
@@ -20,10 +20,8 @@
#ifndef UKWS_WINDOW_INFO_H
#define UKWS_WINDOW_INFO_H
-extern "C" {
#define WNCK_I_KNOW_THIS_IS_UNSTABLE
#include
-}
#include
#include
diff --git a/src/ukws_wnck_operator.h b/src/ukws_wnck_operator.h
index 6391ad1..d75409e 100644
--- a/src/ukws_wnck_operator.h
+++ b/src/ukws_wnck_operator.h
@@ -20,10 +20,8 @@
#ifndef UKWS_WNCK_OPERATOR_H
#define UKWS_WNCK_OPERATOR_H
-extern "C" {
#define WNCK_I_KNOW_THIS_IS_UNSTABLE
#include
-}
#include
diff --git a/src/ukws_workspace_box.h b/src/ukws_workspace_box.h
index 1023ca7..a039e06 100644
--- a/src/ukws_workspace_box.h
+++ b/src/ukws_workspace_box.h
@@ -20,11 +20,9 @@
#ifndef UKWSWORKSPACEBOX_H
#define UKWSWORKSPACEBOX_H
-extern "C" {
#define WNCK_I_KNOW_THIS_IS_UNSTABLE
#include
#include
-}
#include "ukws_window_extra_label.h"
#include "ukws_wnck_operator.h"