X11 headers not compliant with ISO C++ 17

Discuss issues related to installing or building
Post Reply
gh_origin
Posts: 14
Joined: Sat Jul 18 2020 4:23 pm

X11 headers not compliant with ISO C++ 17

Post by gh_origin »

It caused the build to be fail.

Error message:

Code: Select all

[3789/3821] /usr/bin/c++    @src/plugins/platforms/CMakeFiles/CsGuiXcb.dir/xcb/qxcbconnection.cpp.o.rsp -MD -MT src/plugins/platforms/CMakeFiles/CsGuiXcb.dir/xcb/qxcbconnection.cpp.o -MF src/plugins/platforms/CMakeFiles/CsGuiXcb.dir/xcb/qxcbconnection.cpp.o.d -o src/plugins/platforms/CMakeFiles/CsGuiXcb.dir/xcb/qxcbconnection.cpp.o -c ../src/plugins/platforms/xcb/qxcbconnection.cpp
FAILED: src/plugins/platforms/CMakeFiles/CsGuiXcb.dir/xcb/qxcbconnection.cpp.o 
/usr/bin/c++    @src/plugins/platforms/CMakeFiles/CsGuiXcb.dir/xcb/qxcbconnection.cpp.o.rsp -MD -MT src/plugins/platforms/CMakeFiles/CsGuiXcb.dir/xcb/qxcbconnection.cpp.o -MF src/plugins/platforms/CMakeFiles/CsGuiXcb.dir/xcb/qxcbconnection.cpp.o.d -o src/plugins/platforms/CMakeFiles/CsGuiXcb.dir/xcb/qxcbconnection.cpp.o -c ../src/plugins/platforms/xcb/qxcbconnection.cpp
In file included from ../src/plugins/platforms/xcb/qxcbconnection.cpp:24:
In file included from ../src/plugins/platforms/xcb/qxcbconnection.h:31:
In file included from include/QtCore/QHash:1:
In file included from include/QtCore/qhash.h:31:
In file included from include/QtCore/qhashfunc.h:28:
In file included from include/QtCore/qpair.h:28:
In file included from include/QtCore/qdatastream.h:29:
In file included from include/QtCore/qiodevice.h:27:
In file included from include/QtCore/qobject.h:32:
In file included from include/QtCore/qmetaobject.h:30:
In file included from include/QtCore/csmeta.h:28:
In file included from include/QtCore/csmeta_internal_1.h:30:
include/QtCore/qvariant.h:534:32: warning: 'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
   std::shared_ptr<CustomType> clone() const {
                               ^
include/QtGui/qpixmap.h:215:13: note: in instantiation of template class 'CustomType_T<QPixmap>' requested here
inline bool CustomType_T<QPixmap>::compare(const CustomType &other) const {
            ^
include/QtCore/qvariant.h:451:46: note: overridden virtual function is here
         virtual std::shared_ptr<CustomType> clone() const = 0;
                                             ^
include/QtCore/qvariant.h:534:32: warning: 'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
   std::shared_ptr<CustomType> clone() const {
                               ^
include/QtGui/qicon.h:137:13: note: in instantiation of template class 'CustomType_T<QIcon>' requested here
inline bool CustomType_T<QIcon>::compare(const CustomType &other) const {
            ^
include/QtCore/qvariant.h:451:46: note: overridden virtual function is here
         virtual std::shared_ptr<CustomType> clone() const = 0;
                                             ^
include/QtCore/qvariant.h:534:32: warning: 'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
   std::shared_ptr<CustomType> clone() const {
                               ^
include/QtGui/qcursor.h:118:13: note: in instantiation of template class 'CustomType_T<QCursor>' requested here
inline bool CustomType_T<QCursor>::compare(const CustomType &other) const {
            ^
include/QtCore/qvariant.h:451:46: note: overridden virtual function is here
         virtual std::shared_ptr<CustomType> clone() const = 0;
                                             ^
In file included from ../src/plugins/platforms/xcb/qxcbconnection.cpp:59:
/usr/local/include/X11/Xlibint.h:678:7: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
             register _Xconst long *data,
             ^~~~~~~~~
/usr/local/include/X11/Xlibint.h:683:7: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
             register long *data,
             ^~~~~~~~~
/usr/local/include/X11/Xlibint.h:1385:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    register Display *dpy,
    ^~~~~~~~~
/usr/local/include/X11/Xlibint.h:1387:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    register unsigned long valuemask,
    ^~~~~~~~~
/usr/local/include/X11/Xlibint.h:1388:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    register XSetWindowAttributes *attributes);
    ^~~~~~~~~
/usr/local/include/X11/Xlibint.h:1398:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    register Display *dpy,
    ^~~~~~~~~
/usr/local/include/X11/Xlibint.h:1406:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    register Display *dpy,
    ^~~~~~~~~
/usr/local/include/X11/Xlibint.h:1411:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    register Display *dpy,
    ^~~~~~~~~
/usr/local/include/X11/Xlibint.h:1412:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    register XEvent *event);
    ^~~~~~~~~
3 warnings and 9 errors generated.
ansel
Posts: 152
Joined: Fri Apr 10 2015 8:23 am

Re: X11 headers not compliant with ISO C++ 17

Post by ansel »

You are correct that the C++17 standard does not allow the register keyword. GCC only reports this as a warning while clang reports it as an error. The workaround for this is to build with the -Wno-register flag which disables this error in clang. We considered enabling this automatically in our CMake files but this seemed awkward. We're open to re-visiting that decision.
Ansel Sermersheim
CopperSpice Cofounder
gh_origin
Posts: 14
Joined: Sat Jul 18 2020 4:23 pm

Re: X11 headers not compliant with ISO C++ 17

Post by gh_origin »

ansel wrote: Fri Jul 31 2020 11:15 pm You are correct that the C++17 standard does not allow the register keyword. GCC only reports this as a warning while clang reports it as an error. The workaround for this is to build with the -Wno-register flag which disables this error in clang. We considered enabling this automatically in our CMake files but this seemed awkward. We're open to re-visiting that decision.
Thank you. With your advise and all of the ugly symlinks workaround I used, I have two successful builds now. One build is with Clang (the system compiler). One build is with GCC (installed from binary package).

All of the symlinks I created, and I confirmed that I still need them for the build to be success:

Code: Select all

doas ln -s /usr/local/include/iconv.h /usr/include/iconv.h
doas ln -s /usr/local/lib/libiconv.so /usr/lib/libiconv.so
doas ln -s /usr/local/lib/libcups.so /usr/lib/libcups.so
Post Reply