Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy.h breaks when used from C++, and breaks qtbase #226

Closed
0-wiz-0 opened this issue May 21, 2023 · 13 comments · Fixed by #230
Closed

proxy.h breaks when used from C++, and breaks qtbase #226

0-wiz-0 opened this issue May 21, 2023 · 13 comments · Fixed by #230
Labels

Comments

@0-wiz-0
Copy link
Contributor

0-wiz-0 commented May 21, 2023

qt5-qtbase 5.15.9 has two issues with libproxy 0.5
a) it expects to find libproxy.h directly in the search path and doesn't seem to use pkg-config to get the proper CFLAGS

when I work around a) it fails because
b) it tries to use a c++ compiler, and this fails with:

In file included from /scratch/x11/qt5-qtbase/work/.buildlink/include/glib-2.0/glib/glib-typeof.h:44,
                 from /scratch/x11/qt5-qtbase/work/.buildlink/include/glib-2.0/glib/gatomic.h:30,
                 from /scratch/x11/qt5-qtbase/work/.buildlink/include/glib-2.0/glib/gthread.h:34,
                 from /scratch/x11/qt5-qtbase/work/.buildlink/include/glib-2.0/glib/gasyncqueue.h:34,
                 from /scratch/x11/qt5-qtbase/work/.buildlink/include/glib-2.0/glib.h:34,
                 from /scratch/x11/qt5-qtbase/work/.buildlink/include/glib-2.0/gobject/gbinding.h:30,
                 from /scratch/x11/qt5-qtbase/work/.buildlink/include/glib-2.0/glib-object.h:24,
                 from /scratch/x11/qt5-qtbase/work/.buildlink/include/glib-2.0/gio/gioenums.h:30,
                 from /scratch/x11/qt5-qtbase/work/.buildlink/include/glib-2.0/gio/giotypes.h:30,
                 from /scratch/x11/qt5-qtbase/work/.buildlink/include/glib-2.0/gio/gio.h:28,
                 from /scratch/x11/qt5-qtbase/work/.buildlink/include/proxy.h:29,
                 from main.cpp:2:
/usr/include/g++/type_traits:56:3: error: template with C linkage
   56 |   template<typename _Tp, _Tp __v>
      |   ^~~~~~~~
In file included from main.cpp:2:
/scratch/x11/qt5-qtbase/work/.buildlink/include/proxy.h:26:1: note: 'extern "C"' linkage started here
   26 | extern "C" {
      | ^~~~~~~~~~

This patch fixes the second problem:

--- src/libproxy/proxy.h.orig   2023-05-15 13:09:42.000000000 +0000
+++ src/libproxy/proxy.h
@@ -22,12 +22,12 @@
 
 #pragma once
 
+#include <gio/gio.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include <gio/gio.h>
-
 /**
  * SECTION:px-proxy
  * @short_description: A convient helper for using proxy servers
@0-wiz-0
Copy link
Contributor Author

0-wiz-0 commented May 22, 2023

But even with this fix, qt5-qtbase doesn't build because the combination of glib and qt headers doesn't work:

In file included from ../../include/QtCore/qobjectdefs.h:1,                                                                                                                                               from ../../include/QtCore/../../src/corelib/kernel/qobject.h:46,                                                                                                                         from ../../include/QtCore/qobject.h:1,                                                                                                                                                   from ../../include/QtCore/../../src/corelib/io/qiodevice.h:45,                                                                                                                           from ../../include/QtCore/qiodevice.h:1,
                 from ../../include/QtNetwork/../../src/network/socket/qabstractsocket.h:44, 
                 from ../../include/QtNetwork/qabstractsocket.h:1,
                 from ../../include/QtNetwork/../../src/network/kernel/qhostaddress.h:48,
                 from ../../include/QtNetwork/qhostaddress.h:1,
                 from kernel/qnetworkproxy.h:44,                         
                 from kernel/qnetworkproxy_libproxy.cpp:41:
../../include/QtCore/../../src/corelib/kernel/qobjectdefs.h:93:20: error: expected unqualified-id before 'public'
   93 | # define Q_SIGNALS public QT_ANNOTATE_ACCESS_SPECIFIER(qt_signal)
      |                    ^~~~~~                                                           
../../include/QtCore/../../src/corelib/kernel/qobjectdefs.h:89:22: note: in expansion of macro 'Q_SIGNALS'
   89 | #     define signals Q_SIGNALS                                                      
      |                      ^~~~~~~~~                                                                                                                                                   
/scratch/x11/qt5-qtbase/work/.buildlink/include/glib-2.0/gio/gdbusintrospection.h:157:25: note: in expansion of macro 'signals'
  157 |   GDBusSignalInfo     **signals; 
      |                         ^~~~~~~

@0-wiz-0
Copy link
Contributor Author

0-wiz-0 commented May 22, 2023

qy6-qtbase 6.5.0 doesn't build either, I'm not completely sure why, but source file has libproxy in its name:

In file included from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtCore/qtmetamacros.h:1,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtCore/../../src/corelib/global/qnamespace.h:13,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtCore/qnamespace.h:1,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtCore/../../src/corelib/text/qbytearray.h:9,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtCore/qbytearray.h:1,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtCore/../../src/corelib/text/qstringview.h:8,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtCore/qstringview.h:1,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtCore/../../src/corelib/text/qchar.h:656,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtCore/qchar.h:1,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtCore/../../src/corelib/text/qstring.h:14,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtCore/qstring.h:1,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtNetwork/../../src/network/kernel/qhostaddress.h:10,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtNetwork/qhostaddress.h:1,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/src/network/kernel/qnetworkproxy.h:8,
                 from /scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/src/network/kernel/qnetworkproxy_libproxy.cpp:5:
/scratch/x11/qt6-qtbase/work/qtbase-everywhere-src-6.5.0/include/QtCore/../../src/corelib/kernel/qtmetamacros.h:45:20: error: expected unqualified-id before 'public'
   45 | # define Q_SIGNALS public QT_ANNOTATE_ACCESS_SPECIFIER(qt_signal)
      |                    ^~~~~~

@0-wiz-0 0-wiz-0 changed the title proxy.h breaks when used from C++ proxy.h breaks when used from C++, and breaks qtbase May 22, 2023
@janbrummer
Copy link
Contributor

Interesting, header file name hasn't been changed and you could provide a PR for your second issue. It's valid and should be fixed. Not sure yet about the following ones.

@DimStar77 Have you spotted issues on OpenSUSE?

@0-wiz-0
Copy link
Contributor Author

0-wiz-0 commented May 22, 2023

About the header file: it was in ${PREFIX}/include/proxy.h, now it's installed in ${PREFIX}/include/libproxy/proxy.h

0-wiz-0 added a commit to 0-wiz-0/libproxy that referenced this issue May 22, 2023
Fixes usage of header file from C++.

Addresses one part of libproxy#226.
janbrummer pushed a commit that referenced this issue May 22, 2023
Fixes usage of header file from C++

Addresses one part of #226.
@janbrummer
Copy link
Contributor

About the header file: it was in ${PREFIX}/include/proxy.h, now it's installed in ${PREFIX}/include/libproxy/proxy.h

Good catch, yeah. We should fix it as well.

@0-wiz-0
Copy link
Contributor Author

0-wiz-0 commented May 22, 2023

About the header file: it was in ${PREFIX}/include/proxy.h, now it's installed in ${PREFIX}/include/libproxy/proxy.h

Good catch, yeah. We should fix it as well.

I don't know my way around meson, sorry.

@amigadave
Copy link
Contributor

About the header file: it was in ${PREFIX}/include/proxy.h, now it's installed in ${PREFIX}/include/libproxy/proxy.h

Good catch, yeah. We should fix it as well.

I think it would be even better to keep the (new) prefixed location, and simply include that from an unprefixed proxy.h, as that would at least provide the possibility in deprecate the unprefixed location, and drop it in future.

@janbrummer
Copy link
Contributor

In this case we can just leave it the way it is, because now or later apps needs to be adjusted...

@0-wiz-0
Copy link
Contributor Author

0-wiz-0 commented May 22, 2023

Moving the file is a change of the public interface.
(In pkgsrc I'll work around it by providing a symlink until all users are fixed.)

@amigadave
Copy link
Contributor

It depends on how much you want to keep strict API compatibility. Anything that uses pkg-config should not have an issue, at least.

@eli-schwartz
Copy link

Moving the file is a change of the public interface.

No it is not???

Including it without using pkg-config to find it is a use of the private interface.

@janbrummer
Copy link
Contributor

Seems to have fixed it locally, qtbase compilation took a while. Will prepare a PR.

janbrummer added a commit that referenced this issue May 22, 2023
3rd party libraries (like QT) which defines same variable names will
clash if we use gio/gio.h in public proxy.h. Switch to minimal required
to fix compilation issues with QT5/6.

Fixes: #226
@janbrummer
Copy link
Contributor

@0-wiz-0 I do have a PR incoming which fixes my local qt6 build. Could you please verify it?

@janbrummer janbrummer added the Bug label May 22, 2023
janbrummer added a commit that referenced this issue May 22, 2023
3rd party libraries (like QT) which defines same variable names will
clash if we use gio/gio.h in public proxy.h. Switch to minimal required
to fix compilation issues with QT5/6.

Fixes: #226
Martchus pushed a commit to Martchus/qtbase that referenced this issue Jun 13, 2023
>=libproxy-0.5 moved proxy.h into a non-default include search path.

See also:
libproxy/libproxy#226 (comment)
https://bugs.gentoo.org/906879

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
Martchus pushed a commit to Martchus/qtbase that referenced this issue Oct 8, 2023
>=libproxy-0.5 moved proxy.h into a non-default include search path.

See also:
libproxy/libproxy#226 (comment)
https://bugs.gentoo.org/906879

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
Martchus pushed a commit to Martchus/qtbase that referenced this issue Jan 7, 2024
>=libproxy-0.5 moved proxy.h into a non-default include search path.

See also:
libproxy/libproxy#226 (comment)
https://bugs.gentoo.org/906879

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
Martchus pushed a commit to Martchus/qtbase that referenced this issue Mar 15, 2024
>=libproxy-0.5 moved proxy.h into a non-default include search path.

See also:
libproxy/libproxy#226 (comment)
https://bugs.gentoo.org/906879

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants