dgcor / DGEngine

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

build error: Dun.cpp, error: storage class specifiers invalid in friend function #39

Closed mewmew closed 3 years ago

mewmew commented 3 years ago

I tried to build the latest release of DGEngine (v0.5, rev 7467db8061c8650fd7651a6260fd6e52b08efb53), but got the following build error:

[  7%] Building CXX object CMakeFiles/DGEngine.dir/src/Dun.cpp.o
In file included from /home/u/life/projects/diablo/DGEngine/src/Dun.h:5,
                 from /home/u/life/projects/diablo/DGEngine/src/Dun.cpp:1:
/home/u/life/projects/diablo/DGEngine/src/Utils/Vector2D.h:31:11: error: declaration of template parameter ‘T’ shadows template parameter
   31 |  template<std::integral T>
      |           ^~~
/home/u/life/projects/diablo/DGEngine/src/Utils/Vector2D.h:16:10: note: template parameter ‘T’ declared here
   16 | template<std::integral T>
      |          ^~~
/home/u/life/projects/diablo/DGEngine/src/Utils/Vector2D.h:32:2: error: storage class specifiers invalid in friend function declarations
   32 |  static friend T& get(size_t x, size_t y, Vector2D<T>& vec)
      |  ^~~~~~
/home/u/life/projects/diablo/DGEngine/src/Utils/Vector2D.h:37:11: error: declaration of template parameter ‘T’ shadows template parameter
   37 |  template<std::integral T>
      |           ^~~
/home/u/life/projects/diablo/DGEngine/src/Utils/Vector2D.h:16:10: note: template parameter ‘T’ declared here
   16 | template<std::integral T>
      |          ^~~
/home/u/life/projects/diablo/DGEngine/src/Utils/Vector2D.h:38:2: error: storage class specifiers invalid in friend function declarations
   38 |  static friend const T& get(size_t x, size_t y, const Vector2D<T>& vec)
      |  ^~~~~~
make[2]: *** [CMakeFiles/DGEngine.dir/build.make:225: CMakeFiles/DGEngine.dir/src/Dun.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/DGEngine.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

Build environment:

u@x1 ~/l/p/d/D/build (master)> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC) 

u@x1 ~/l/p/d/D/build (master)> clang -v
clang version 11.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

u@x1 ~/l/p/d/D/build (master)> uname -a
Linux x1 5.10.4-arch2-1 #1 SMP PREEMPT Fri, 01 Jan 2021 05:29:53 +0000 x86_64 GNU/Linux
ghost commented 3 years ago

Thanks for testing. I forgot to test that last change in gcc. And my linux CI script stopped working, for some reason. It should be fixed now.

mewmew commented 3 years ago

Great! Now it works flawlessly.