hugoam / toy

the thin c++ game engine
https://toyengine.io
GNU General Public License v3.0
1.57k stars 101 forks source link

Can't compile #1

Closed f0086 closed 6 years ago

f0086 commented 6 years ago

I compiled straight from git HEAD:

...
In file included from ../../../src/core/Core.h:10,
                 from ../../../src/core/Core.cpp:7:
../../../src/core/World/Section.h:97:15: error: ‘function’ in namespace ‘std’ does not name a template type
  typedef std::function<void()> TaskFunc;
               ^~~~~~~~
../../../src/core/World/Section.h:97:10: note: ‘std::function’ is defined in header ‘<functional>’; did you forget to ‘#include <functional>’?
../../../src/core/World/Section.h:18:1:
+#include <functional>
 #endif
../../../src/core/World/Section.h:97:10:
  typedef std::function<void()> TaskFunc;
          ^~~
../../../src/core/World/Section.h:109:17: error: ‘TaskFunc’ has not been declared
   void add_task(TaskFunc task) { m_task_queue.push(task); }
                 ^~~~~~~~
../../../src/core/World/Section.h:113:17: error: ‘TaskFunc’ was not declared in this scope
   LocklessQueue<TaskFunc> m_task_queue;
                 ^~~~~~~~
../../../src/core/World/Section.h:113:17: note: suggested alternative: ‘Task’
   LocklessQueue<TaskFunc> m_task_queue;
                 ^~~~~~~~
                 Task
../../../src/core/World/Section.h:113:25: error: template argument 1 is invalid
   LocklessQueue<TaskFunc> m_task_queue;
                         ^
../../../src/core/World/Section.h: In member function ‘void toy::QueueSection::add_task(int)’:
../../../src/core/World/Section.h:109:47: error: request for member ‘push’ in ‘((toy::QueueSection*)this)->toy::QueueSection::m_task_queue’, which is of non-class type  int’
   void add_task(TaskFunc task) { m_task_queue.push(task); }
                                               ^~~~
EventFilter.cpp
make[1]: *** [toy.make:836: ../../linux64_gcc/obj/x64/Debug/toy/src/core/Core.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:93: toy] Error 2

Looks like some C++ version mismatch?

└─ $ ▶ g++ --version
g++ (GCC) 8.1.1 20180531
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
hugoam commented 6 years ago

Fixed: https://github.com/hugoam/toy/commit/8064852ee74aed7a2a7b47ba455f4f43c86d595f I suppose depending on the standard library version, <functional> was already included by another of the std headers included by that file, but not with the one you're using.