Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Odd error with headers
Forum Updated to NodeBB v4.3 + New Features

Odd error with headers

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 418 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndrzejB
    wrote on last edited by AndrzejB
    #1

    GCC give me errors:

    In file included from /usr/include/X11/Xlib.h:44,
    from /home/andrzej/wazne/proj/minimal_odd_conflict/Win.h:4,
    from /home/andrzej/wazne/proj/minimal_odd_conflict/Win.cpp:1:
    /usr/include/x86_64-linux-gnu/qt5/QtCore/qnamespace.h:1199:10: error: expected identifier before numeric constant
    1199 |     enum CursorShape {
    

    although Xlib.h doesn't include qnamespace.h
    Preprocessor only (make make Win.cpp.i) is usual
    This is not GCC error, because error is also in Clang, although errors is clearer than GCC - about MOC

    In file included from /home/andrzej/wazne/proj/minimal_odd_conflict/Win.cpp:2:
    In file included from /home/andrzej/wazne/proj/minimal_odd_conflict/EdiException.h:7:
    In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/QString:1:
    In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/qstring.h:50:
    In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/qbytearray.h:45:
    /usr/include/x86_64-linux-gnu/qt5/QtCore/qnamespace.h:1199:10: error: expected identifier or '{'
    enum CursorShape {
    

    I attach minimal project minimal_odd_conflict.zip

    Solution:
    is enough in Win.cpp

    #include "Win.h"
    #undef CursorShape
    #include "EdiException.h"
    
    1 Reply Last reply
    0
    • kkoehneK Offline
      kkoehneK Offline
      kkoehne
      Moderators
      wrote on last edited by
      #2

      X11/X.h contains something like '#define CursorShape 0', which conflicts with the Qt header trying to declare CursorShape as an enum.

      This can be solved by making sure Qt headers are included first, and then only system headers.

      Director R&D, The Qt Company

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved