weigert / SimpleHydrology

Procedural Hydrology / River / Lake Simulation
611 stars 43 forks source link

Compilation error #3

Closed msokalski closed 12 months ago

msokalski commented 3 years ago
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?

weigert commented 3 years ago

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.

msokalski commented 3 years ago

Thank you!