ec429/harris

Compilation error while building "globals.h:27: 'NEVENTS' not declared here"

florian-s-code opened this issue · 4 comments

I get the following error on Arch Linux.
It looks like an error in the code rather than a misconfiguration on my part.

$ make
cc -Wall -Wextra -Werror --std=gnu11 -g -DDATIDIR=\"/usr/local/share/games/harris\" -DUSAVDIR=\".local/share/harris\"  `sdl-config --cflags` -o harris.o -c harris.c
In file included from harris.c:29:0:
globals.h:27:19: error: ‘NEVENTS’ undeclared here (not in a function)
 extern date event[NEVENTS];
                   ^
Makefile:47: recipe for target 'harris.o' failed
ec429 commented

Hmm. NEVENTS should be defined in events.h, which is generated by a Python program (mkevents.py).

  • Do you have Python installed?
  • Try make events.h, in case there's some missing deps in the Makefile. If it fails, please post the error.

The Diagnosis

  • Do you have Python Python v2 installed?
    (see the next section below for an explanation of my textual strikeout)
  • Try make events.h make realclean ; make events.h, in case there's some missing deps in the Makefile. If it fails, please post the error.
    (users who are seeing @yhoyhoj 's error will need to begin by deleting the zero-length events.h that was generated during a prior make process that could not finish)

The Underlying Issue

The reason that make is aborting is that mkevents.py, and also all the other *.py scripts, use Python v2's print statement syntax that is not compatible with Python v3. Per @ec429 's request, I've run make events.h and the following error reveals what it is that needs to be addressed:

./mkevents.py h >events.h
  File "./mkevents.py", line 21
    """
      ^
SyntaxError: invalid syntax
make: *** [Makefile:50: events.h] Error 1

My Suggested Resolution

Note that on my Arch Linux system, /usr/bin/python is Python v3 and /usr/bin/python2 is Python v2. I've submitted a pull request that modifies the Python scripts so they will execute with either version of Python, no matter which one or both is installed.

ec429 commented

Thanks for tracking this down, @zero2cx !

ec429 commented

Should be fixed by 8a7ae74.