Closed VanLaser closed 9 years ago
@VanLaser
Without including <cstddef.h>
, which lines are producing errors when compiling (if any)? I do not recall using NULL
, but I did use nullptr
for std::stoi
calls in game.cpp and perhaps that is causing the problem. Everything works fine on my system (Ubuntu), but I will update the repo if it fixes other systems (like Arch Linux)
Thanks for bringing this up.
It's somehow caused by the ncurses library:
$g++ src/game.cpp -pthread -std=c++11 -lncurses src/globals.cpp src/helperFns.cpp src/avatar.cpp src/ghost1.cpp -o pacvim
In file included from /usr/include/cursesw.h:36:0,
from src/globals.h:6,
from src/globals.cpp:1:
/usr/include/etip.h: In constructor ‘NCursesPanelException::NCursesPanelException(const char*, int)’:
/usr/include/etip.h:187:8: error: ‘NULL’ was not declared in this scope
p (NULL)
^
(and a bunch of other similar errors, from the same file)
$ pacman -Q ncurses
ncurses 5.9-7
scratches head Interesting...
I will test this on a couple machines later today just to make sure nothing else breaks from any changes. To confirm, adding <cstddef>
(and NOT <cstddef.h>
, according to here), before the ncurses include in globals.h
resolves all your issues on Arch Linux?
Thanks, @VanLaser
Yes, including <cstddef>
was enough to build the executable (and it also runs all right). And it can't be <cstddef.h>
- if memory serves right, it's either <stddef.h>
, or <cstddef>
(2nd form preferred for inclusion in c++ programs).
BTW, thanks for making the program!
EDIT: Only later I realized that I was the one mentioning the <cstddef.h>
typo in the first place (and post). Sorry! It's, of course, <cstddef>
I can confirm that it does not compile under Arch Linux with gcc (4.9.2) and ncurses (5.9-7). Furthermore, the following patch (as suggested by @VanLaser) does indeed fix it
diff --git a/src/globals.h b/src/globals.h
index 9379412..39efddc 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -1,6 +1,7 @@
#ifdef __APPLE__
#include <ncursesw/cursesw.h>
#else
+#include <cstddef>
#include <cursesw.h>
#endif
@VanLaser Thanks for the assistance, and don't worry about the typo :p
@pato Thanks for confirming the bug and VanLaser's fix
I updated the main repo to include this change
Hi, on Linux (at least Arch Linux, with gcc 4.9.2), the
src/globals.h
needs to include<cstddef.h>
before including the curses library, otherwise NULL is not recognized.EDIT: yes, the
<cstddef.h>
with a suffix - was a typo