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

FIX: build when using X11 #811

Merged
merged 1 commit into from
Oct 12, 2023
Merged

FIX: build when using X11 #811

merged 1 commit into from
Oct 12, 2023

Conversation

ismagilli
Copy link
Contributor

@ismagilli ismagilli commented Oct 12, 2023

The problem occurs when trying to build a game using X11.
There is such a line in the X11/X.h file:

/*****************************************************************
* RESERVED RESOURCE AND CONSTANT DEFINITIONS
*****************************************************************/
...
#define AnyKey     0L /* special Key Code, passed to GrabKey */

At the same time, in the doomretro code, there is the following enum in the p_spec.h file:

// define names for the locked door Kind field of the general ceiling
enum
{
    AnyKey,
    ...
};

Include chain:

i_video.c:37: #include <X11/Xlib.h>
    /usr/include/X11/Xlib.h:44: #include <X11/X.h>
i_video.c:55: #include "m_config.h"
    m_config.h:39: #include "p_local.h"
    p_local.h:341: #include "p_spec.h"

Therefore, a problem occurs when compiling i_video.c:

cc -O2 -fsigned-char -g `sdl2-config --cflags` -DX11 -c i_video.c -o i_video.o
In file included from /usr/include/X11/Xlib.h:44,
                from i_video.c:37:
p_spec.h:822:5: error: expected identifier before numeric constant
822 |     AnyKey,
    |     ^~~~~~
make: *** [Makefile:55: i_video.o] Error 1

It is reproduced on many popular linux distributions.

One of the possible ways is to reproduce:

  1. Use ubuntu docker container: docker run -it ubuntu bash;
  2. Update list of available packages: # apt update;
  3. Upgrade the system: # apt upgrade -y;
  4. Install required packages: # apt install -y git gcc make libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev;
  5. Clone doomretro repo: $ git clone https://github.com/bradharding/doomretro;
  6. Enter source directory: $ cd doomretro/src;
  7. Build i_video.c: $ make i_video.o.

Commands 2-4 and 5-7 can be combined into 2 commands:

  1. # apt update && apt upgrade -y && apt install -y git gcc make libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev;
  2. $ git clone https://github.com/bradharding/doomretro && cd doomretro/src && make i_video.o.

@bradharding bradharding merged commit 09bb964 into bradharding:master Oct 12, 2023
1 check passed
@bradharding
Copy link
Owner

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants