SimpleHydrology icon indicating copy to clipboard operation
SimpleHydrology copied to clipboard

Compilation error

Open msokalski opened this issue 3 years ago • 2 comments

g++ -std=c++17 SimpleHydrology.cpp TinyEngine/include/imgui/imgui.cpp TinyEngine/include/imgui/imgui_demo.cpp TinyEngine/include/imgui/imgui_draw.cpp TinyEngine/include/imgui/imgui_widgets.cpp TinyEngine/include/imgui/imgui_impl_opengl3.cpp TinyEngine/include/imgui/imgui_impl_sdl.cpp -Wfatal-errors -O3 -I/usr/local/include -L/usr/local/lib -lnoise -lX11 -lpthread -lSDL2 -lnoise -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lGL -lGLEW -lboost_serialization -lboost_system -lboost_filesystem -o hydrology
In file included from SimpleHydrology.cpp:3:
source/world.h:208:46: error: non-local lambda expression cannot have a capture-default
  208 | std::function<void(Model* m)> constructor = [&](Model* m){
      |                                              ^
compilation terminated due to -Wfatal-errors.
make: *** [makefile:11: all] Error 1

Is there anything I can do other than tweaking the source code?

msokalski avatar Jun 21 '21 09:06 msokalski

This is a weird bug that keeps coming up. Because it once worked for me, I wonder if this is something that changed with compiler versions.

The direct fix is to simply remove the ampersand (just delete it from the brackets, i.e. [&] to []) where the error comes up.

I need to fix this with a pull request.

weigert avatar Jun 21 '21 09:06 weigert

Thank you!

msokalski avatar Jun 21 '21 09:06 msokalski