Closed ChairManMeow-SY closed 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 gccWith
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.
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 Withbar() = 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.
環境 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'.