wx/layout.h error: expected unqualified-id before numeric constant

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
dizcza
In need of some credit
In need of some credit
Posts: 8
Joined: Tue May 30, 2023 1:14 pm

wx/layout.h error: expected unqualified-id before numeric constant

Post by dizcza »

I'm building Mediapipe + OpenCV + wxWidges in Bazel.

I've done a lot in setting things up but when I import <wx/wx.h> in my main cpp file I get

Code: Select all

1685452043.516973003: src/main/tools/linux-sandbox-pid1.cc:481: child started with PID 2
In file included from /usr/include/X11/extensions/XInput.h:53,
                 from /usr/include/X11/extensions/XTest.h:32,
                 from ./mediapipe/examples/desktop/airtouch_hand_tracking/action_sender.h:11,
                 from ./mediapipe/examples/desktop/airtouch_hand_tracking/airtouch.h:11,
                 from mediapipe/examples/desktop/airtouch_hand_tracking/airtouch_main.cc:35:
external/wx/wx/layout.h:96:10: error: expected unqualified-id before numeric constant
   96 |     void Absolute(int val);
      |          ^~~~~~~~
1685452048.645893276: src/main/tools/linux-sandbox-pid1.cc:498: wait returned pid=2, status=0x100
1685452048.645910299: src/main/tools/linux-sandbox-pid1.cc:516: child exited normally with code 1
It may be that Absolute is defined elsewhere and hence is the error. Any idea?

wxWidgets v3.2.2.1, Ubuntu 22.04

------

Update 1.

My guess was correct.

Code: Select all

#define Absolute                1
is defined in "XI.h".

A workaround would be to "undef Absolute" on the user side but this is silly. Please consider another fix.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wx/layout.h error: expected unqualified-id before numeric constant

Post by doublemax »

dizcza wrote: Tue May 30, 2023 1:18 pm My guess was correct.

Code: Select all

#define Absolute                1
is defined in "XI.h".

A workaround would be to "undef Absolute" on the user side but this is silly. Please consider another fix.
If there is a name conflict between user code and the library, you should fix that in user code. Maybe you can work around it by just changing the order of #includes?
Use the source, Luke!
dizcza
In need of some credit
In need of some credit
Posts: 8
Joined: Tue May 30, 2023 1:14 pm

Re: wx/layout.h error: expected unqualified-id before numeric constant

Post by dizcza »

If there is a name conflict between user code and the library, you should fix that in user code. Maybe you can work around it by just changing the order of #includes?
It's not in the user code, it's in the X11 library as I said.

Anyway, unsettling this define or perhaps playing with the include order will do the trick. A hacky one.
Post Reply