elonafoobar / elonafoobar

One of the Elona variants
https://elonafoobar.com
MIT License
155 stars 36 forks source link

Can not compile on deepin (Debian-like OS) #1507

Closed ChairManMeow-SY closed 4 years ago

ChairManMeow-SY commented 4 years ago

環境 Environment

詳細 Details

When compiling the source code on my machine, an error is thrown out as following:

/home/heathcliff/Software/elonafoobar-0.5.0/src/snail/backends/sdl/renderer.cpp:162:37: error: cannot call member function ‘SDL_Renderer* elona::snail::Renderer::ptr()’ without object ::SDL_RenderCopy(ptr(), texture, nullptr, &dst));

It looks like that the function ptr() is used without specifying the instance.

再現方法 How to reproduce

Just do as instructed in README. First install all needed libraries and then 'make build'.

ki-foobar commented 4 years ago

It is a compiler's bug, not the source code's.

I found a similar question in stackoverflow: https://stackoverflow.com/questions/32097759/calling-this-member-function-from-generic-lambda-clang-vs-gcc

Question: Calling this member function from generic lambda - clang vs gcc

With bar() = call([this](auto x){ foo(x); });

  • clang++ 3.6+ compiles.
  • g++ 5.2+ does not compile.

    error: cannot call member function 'void Example::foo(int)' without object call([this](auto x){ foo(x); });`

Answer: This is a gcc bug.

According to that, old GCC seems to fail to compile such code. Please update your compiler. At least, GCC 7.x can compile that.

ChairManMeow-SY commented 4 years ago

It is a compiler's bug, not the source code's.

I found a similar question in stackoverflow: https://stackoverflow.com/questions/32097759/calling-this-member-function-from-generic-lambda-clang-vs-gcc

Question: Calling this member function from generic lambda - clang vs gcc With bar() = call([this](auto x){ foo(x); });

  • clang++ 3.6+ compiles.
  • g++ 5.2+ does not compile.

error: cannot call member function 'void Example::foo(int)' without object call([this](auto x){ foo(x); });`

Answer: This is a gcc bug.

According to that, old GCC seems to fail to compile such code. Please update your compiler. At least, GCC 7.x can compile that.

Thanks for the reply. I have updated my compiler to 7.5 (as shown in the figure) but the bug still exists. I'll try 8.x and 9.x later. I hope they will work. DeepinScreenshot_dde-desktop_20200127112559