dgcor / DGEngine

An implementation of the Diablo 1 game engine
Other
243 stars 30 forks source link

Compile error for v0.3.0 #21

Closed mewmew closed 5 years ago

mewmew commented 5 years ago

I just tried to build the v0.3.0 release of DGEngine, and got the follow compile time error:

u@x1 ~/D/d/DGEngine> mkdir build
u@x1 ~/D/d/DGEngine> cd build
u@x1 ~/D/d/D/build> cmake ..
-- The C compiler identification is GNU 8.2.1
-- The CXX compiler identification is GNU 8.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
--  Found avcodec: /usr/include /usr/lib/libavcodec.so
--  Found avdevice: /usr/include /usr/lib/libavdevice.so
--  Found avfilter: /usr/include /usr/lib/libavfilter.so
--  Found avformat: /usr/include /usr/lib/libavformat.so
--  Found avutil: /usr/include /usr/lib/libavutil.so
--  Found swresample: /usr/include /usr/lib/libswresample.so
--  Found swscale: /usr/include /usr/lib/libswscale.so
-- Found FFmpeg: /usr/include  found components:  avcodec avformat avutil swscale 
-- Found PhysFS: /usr/lib/libphysfs.so  
-- Found SFML 2.5.1 in /usr/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/u/Desktop/diablo/DGEngine/build
u@x1 ~/D/d/D/build> make
Scanning dependencies of target DGEngine
[  0%] Building CXX object CMakeFiles/DGEngine.dir/src/Main.cpp.o
/home/u/Desktop/diablo/DGEngine/src/Main.cpp: In function ‘int main(int, char**)’:
/home/u/Desktop/diablo/DGEngine/src/Main.cpp:31:24: warning: catching polymorphic type ‘class std::exception’ by value [-Wcatch-value=]
  catch (std::exception ex)
                        ^~
[  1%] Building CXX object CMakeFiles/DGEngine.dir/src/Animation.cpp.o
In file included from /home/u/Desktop/diablo/DGEngine/src/Animation.h:3,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.cpp:1:
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:13:12: error: ‘size_t’ was not declared in this scope
  std::pair<size_t, size_t> textureIndexRange;
            ^~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:13:12: note: suggested alternative:
In file included from /usr/include/c++/8.2.1/utility:68,
                 from /home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:8,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.h:3,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.cpp:1:
/usr/include/c++/8.2.1/x86_64-pc-linux-gnu/bits/c++config.h:238:26: note:   ‘std::size_t’
   typedef __SIZE_TYPE__  size_t;
                          ^~~~~~
In file included from /home/u/Desktop/diablo/DGEngine/src/Animation.h:3,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.cpp:1:
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:13:20: error: ‘size_t’ was not declared in this scope
  std::pair<size_t, size_t> textureIndexRange;
                    ^~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:13:20: note: suggested alternative:
In file included from /usr/include/c++/8.2.1/utility:68,
                 from /home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:8,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.h:3,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.cpp:1:
/usr/include/c++/8.2.1/x86_64-pc-linux-gnu/bits/c++config.h:238:26: note:   ‘std::size_t’
   typedef __SIZE_TYPE__  size_t;
                          ^~~~~~
In file included from /home/u/Desktop/diablo/DGEngine/src/Animation.h:3,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.cpp:1:
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:13:26: error: template argument 1 is invalid
  std::pair<size_t, size_t> textureIndexRange;
                          ^
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:13:26: error: template argument 2 is invalid
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:14:2: error: ‘size_t’ does not name a type
  size_t currentTextureIdx{ 0 };
  ^~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:14:2: note: ‘size_t’ is defined in header ‘<cstddef>’; did you forget to ‘#include <cstddef>’?
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:9:1:
+#include <cstddef>

/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:14:2:
  size_t currentTextureIdx{ 0 };
  ^~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:27:32: error: ‘size_t’ was not declared in this scope
  BaseAnimation(const std::pair<size_t, size_t>& textureIndexRange_,
                                ^~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:27:32: note: suggested alternative:
In file included from /usr/include/c++/8.2.1/utility:68,
                 from /home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:8,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.h:3,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.cpp:1:
/usr/include/c++/8.2.1/x86_64-pc-linux-gnu/bits/c++config.h:238:26: note:   ‘std::size_t’
   typedef __SIZE_TYPE__  size_t;
                          ^~~~~~
In file included from /home/u/Desktop/diablo/DGEngine/src/Animation.h:3,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.cpp:1:
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:27:40: error: ‘size_t’ was not declared in this scope
  BaseAnimation(const std::pair<size_t, size_t>& textureIndexRange_,
                                        ^~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:27:40: note: suggested alternative:
In file included from /usr/include/c++/8.2.1/utility:68,
                 from /home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:8,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.h:3,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.cpp:1:
/usr/include/c++/8.2.1/x86_64-pc-linux-gnu/bits/c++config.h:238:26: note:   ‘std::size_t’
   typedef __SIZE_TYPE__  size_t;
                          ^~~~~~
In file included from /home/u/Desktop/diablo/DGEngine/src/Animation.h:3,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.cpp:1:
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:27:46: error: template argument 1 is invalid
  BaseAnimation(const std::pair<size_t, size_t>& textureIndexRange_,
                                              ^
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:27:46: error: template argument 2 is invalid
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h: In constructor ‘BaseAnimation::BaseAnimation(const int&, const sf::Time&, AnimationType, bool)’:
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:29:44: error: class ‘BaseAnimation’ does not have any field named ‘currentTextureIdx’
   : textureIndexRange(textureIndexRange_), currentTextureIdx(textureIndexRange_.first),
                                            ^~~~~~~~~~~~~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:29:81: error: request for member ‘first’ in ‘textureIndexRange_’, which is of non-class type ‘const int’
   : textureIndexRange(textureIndexRange_), currentTextureIdx(textureIndexRange_.first),
                                                                                 ^~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h: In member function ‘void BaseAnimation::clear()’:
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:34:21: error: request for member ‘first’ in ‘((BaseAnimation*)this)->BaseAnimation::textureIndexRange’, which is of non-class type ‘int’
   textureIndexRange.first = 0;
                     ^~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:35:21: error: request for member ‘second’ in ‘((BaseAnimation*)this)->BaseAnimation::textureIndexRange’, which is of non-class type ‘int’
   textureIndexRange.second = 0;
                     ^~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h: In member function ‘void BaseAnimation::reset()’:
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:40:3: error: ‘currentTextureIdx’ was not declared in this scope
   currentTextureIdx = textureIndexRange.first;
   ^~~~~~~~~~~~~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:40:3: note: suggested alternative: ‘currentTime’
   currentTextureIdx = textureIndexRange.first;
   ^~~~~~~~~~~~~~~~~
   currentTime
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:40:41: error: request for member ‘first’ in ‘((BaseAnimation*)this)->BaseAnimation::textureIndexRange’, which is of non-class type ‘int’
   currentTextureIdx = textureIndexRange.first;
                                         ^~~~~
In file included from /home/u/Desktop/diablo/DGEngine/src/Game/Item.h:4,
                 from /home/u/Desktop/diablo/DGEngine/src/Game/LevelCell.h:5,
                 from /home/u/Desktop/diablo/DGEngine/src/Game/LevelMap.h:5,
                 from /home/u/Desktop/diablo/DGEngine/src/Game/Level.h:8,
                 from /home/u/Desktop/diablo/DGEngine/src/ResourceManager.h:7,
                 from /home/u/Desktop/diablo/DGEngine/src/Game.h:11,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.cpp:2:
/home/u/Desktop/diablo/DGEngine/src/Game/BaseLevelObject.h: In constructor ‘BaseLevelObject::BaseLevelObject(const TexturePack&, const std::pair<long unsigned int, long unsigned int>&, const sf::Time&, AnimationType)’:
/home/u/Desktop/diablo/DGEngine/src/Game/BaseLevelObject.h:53:84: error: no matching function for call to ‘BaseAnimation::BaseAnimation(const std::pair<long unsigned int, long unsigned int>&, const sf::Time&, AnimationType&, bool)’
   : texturePack(&texturePack_), animation(textureIndexRange, frameTime, type, false) {}
                                                                                    ^
In file included from /home/u/Desktop/diablo/DGEngine/src/Animation.h:3,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.cpp:1:
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:27:2: note: candidate: ‘BaseAnimation::BaseAnimation(const int&, const sf::Time&, AnimationType, bool)’
  BaseAnimation(const std::pair<size_t, size_t>& textureIndexRange_,
  ^~~~~~~~~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:27:2: note:   no known conversion for argument 1 from ‘const std::pair<long unsigned int, long unsigned int>’ to ‘const int&’
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:26:2: note: candidate: ‘BaseAnimation::BaseAnimation()’
  BaseAnimation() {}
  ^~~~~~~~~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:26:2: note:   candidate expects 0 arguments, 4 provided
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:10:7: note: candidate: ‘constexpr BaseAnimation::BaseAnimation(const BaseAnimation&)’
 class BaseAnimation
       ^~~~~~~~~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:10:7: note:   candidate expects 1 argument, 4 provided
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:10:7: note: candidate: ‘constexpr BaseAnimation::BaseAnimation(BaseAnimation&&)’
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:10:7: note:   candidate expects 1 argument, 4 provided
/home/u/Desktop/diablo/DGEngine/src/Animation.cpp: In constructor ‘Animation::Animation(const std::shared_ptr<TexturePack>&, const std::pair<long unsigned int, long unsigned int>&, const sf::Time&, AnimationType, bool)’:
/home/u/Desktop/diablo/DGEngine/src/Animation.cpp:7:48: error: no matching function for call to ‘BaseAnimation::BaseAnimation(const std::pair<long unsigned int, long unsigned int>&, const sf::Time&, AnimationType&, bool&)’
  base(textureIndexRange, frameTime, type, pause)
                                                ^
In file included from /home/u/Desktop/diablo/DGEngine/src/Animation.h:3,
                 from /home/u/Desktop/diablo/DGEngine/src/Animation.cpp:1:
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:27:2: note: candidate: ‘BaseAnimation::BaseAnimation(const int&, const sf::Time&, AnimationType, bool)’
  BaseAnimation(const std::pair<size_t, size_t>& textureIndexRange_,
  ^~~~~~~~~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:27:2: note:   no known conversion for argument 1 from ‘const std::pair<long unsigned int, long unsigned int>’ to ‘const int&’
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:26:2: note: candidate: ‘BaseAnimation::BaseAnimation()’
  BaseAnimation() {}
  ^~~~~~~~~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:26:2: note:   candidate expects 0 arguments, 4 provided
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:10:7: note: candidate: ‘constexpr BaseAnimation::BaseAnimation(const BaseAnimation&)’
 class BaseAnimation
       ^~~~~~~~~~~~~
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:10:7: note:   candidate expects 1 argument, 4 provided
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:10:7: note: candidate: ‘constexpr BaseAnimation::BaseAnimation(BaseAnimation&&)’
/home/u/Desktop/diablo/DGEngine/src/BaseAnimation.h:10:7: note:   candidate expects 1 argument, 4 provided
/home/u/Desktop/diablo/DGEngine/src/Animation.cpp: In member function ‘void Animation::updateTexture()’:
/home/u/Desktop/diablo/DGEngine/src/Animation.cpp:19:28: error: ‘class BaseAnimation’ has no member named ‘currentTextureIdx’; did you mean ‘currentTime’?
  if (texturePack->get(base.currentTextureIdx, ti) == true)
                            ^~~~~~~~~~~~~~~~~
                            currentTime
make[2]: *** [CMakeFiles/DGEngine.dir/build.make:76: CMakeFiles/DGEngine.dir/src/Animation.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/DGEngine.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

I'm using dgengin/physfs from the Arch Linux AUR: https://aur.archlinux.org/packages/dgengine-physfs-git

And I have the following versions installed for build dependencies:

u@x1 ~> cmake --version
cmake version 3.12.4

u@x1 ~> pacman -Q sfml
sfml 2.5.1-1

u@x1 ~> gcc --version
gcc (GCC) 8.2.1 20180831

Let me know if any further info may help the troubleshooting.

Cheers, /u

ghost commented 5 years ago

These errors are annoying. I compile the project with 3 different compilers on 2 platforms before releasing to avoid these types of errors. As you saw, it's because of a missing size_t definition.

Once the 3 major compilers get modules support, I'm refactoring the code to use them. Hopefully we won't have these problems then.