Libvisual/libvisual

[master] Compile error: ‘std::function’ has not been declared

1480c1 opened this issue · 2 comments

https://travis-ci.com/1480c1/libvisual/jobs/240314548

[ 17%] Building CXX object libvisual/CMakeFiles/libvisual.dir/lv_bin.cpp.o
In file included from /home/travis/build/1480c1/libvisual/libvisual/libvisual/lv_bin.h:28:0,
                 from /home/travis/build/1480c1/libvisual/libvisual/libvisual/lv_bin.cpp:25:
/home/travis/build/1480c1/libvisual/libvisual/libvisual/lv_input.h:84:31: error: ‘std::function’ has not been declared
       void set_callback (std::function<bool (Audio&)> const& callback);
                               ^~~~~~~~
/home/travis/build/1480c1/libvisual/libvisual/libvisual/lv_input.h:84:39: error: expected ‘,’ or ‘...’ before ‘<’ token
       void set_callback (std::function<bool (Audio&)> const& callback);
                                       ^

I got it to compile most of the code on GCC 8.2.0 with the attached patch. It also addresses uninitialized variables - maybe crudely. The patch is against the current git clone, which I maintain locally as v0.4.99.

GCC is still balking at a calloc() in the actor plugin:

[ 40%] Building C object plugins/actor/goom2k4/CMakeFiles/actor_goom2k4.dir/goomsl.c.o
cd /usr/src/libvisual-0.4.99/libvisual-plugins/build/plugins/actor/goom2k4 && /usr/bin/cc -Dactor_goom2k4_EXPORTS -I/usr/src/libvisual-0.4.99/libvisual-plugins
-I/usr/src/libvisual-0.4.99/libvisual-plugins/build -I/usr/src/libvisual-0.4.99/libvisual-plugins/plugins/actor/goom2k4 -I/usr/src/libvisual-0.4.99/libvisual-pl
ugins/build/plugins/actor/goom2k4 -I/usr/include/libvisual-0.5  -fvisibility=hidden -std=c99 -Wall -Wunused -Wmissing-prototypes -Werror -fstrict-aliasing -O3 -
DNDEBUG -fPIC   -Wno-missing-braces -o CMakeFiles/actor_goom2k4.dir/goomsl.c.o   -c /usr/src/libvisual-0.4.99/libvisual-plugins/plugins/actor/goom2k4/goomsl.c
In function ‘gsl_create_fast_iflow’,
    inlined from ‘gsl_compile’ at /usr/src/libvisual-0.4.99/libvisual-plugins/plugins/actor/goom2k4/goomsl.c:1358:3:
/usr/src/libvisual-0.4.99/libvisual-plugins/plugins/actor/goom2k4/goomsl.c:1275:30: error: argument 1 range [18446744071562067968, 18446744073709551615] exceeds
 maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
   fastiflow->mallocedInstr = calloc(number*16, sizeof(FastInstruction));
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/src/libvisual-0.4.99/libvisual-plugins/plugins/actor/goom2k4/goomsl.c:2:
/usr/src/libvisual-0.4.99/libvisual-plugins/plugins/actor/goom2k4/goomsl.c: In function ‘gsl_compile’:
/usr/include/stdlib.h:541:14: note: in a call to allocation function ‘calloc’ declared here
 extern void *calloc (size_t __nmemb, size_t __size)
              ^~~~~~
cc1: all warnings being treated as errors
make[2]: *** [plugins/actor/goom2k4/CMakeFiles/actor_goom2k4.dir/build.make:207: plugins/actor/goom2k4/CMakeFiles/actor_goom2k4.dir/goomsl.c.o] Error 1
make[2]: Leaving directory '/data/dev/libvisual-0.4.99/libvisual-plugins/build'
make[1]: *** [CMakeFiles/Makefile2:1135: plugins/actor/goom2k4/CMakeFiles/actor_goom2k4.dir/all] Error 2
make[1]: Leaving directory '/data/dev/libvisual-0.4.99/libvisual-plugins/build'
make: *** [Makefile:155: all] Error 2

At the moment, the only way to circumvent it, is -Wno-error in the respective line of the build.make file.

libvisual-0.4.99-c++11.patch.txt

This seems to be about building 4366db1 off branch master. I can reproduce the problem (see below).

With GCC 8.2.0 adding an include to <functional> to some files made things compile for me. @svgmuc can you turn that part of your patch into a pull request so it can receive proper review?

Let's address the calloc issue in a dedicated pull request: #81

For reproduction:

# cd "$(mktemp -d)"
# git clone https://github.com/Libvisual/libvisual.git
# cd libvisual/
# mkdir build
# cd build
# cmake ..
# make 
Scanning dependencies of target update-version
Generating version.h
[  0%] Built target update-version
Scanning dependencies of target nls
[  1%] Generating libvisual.pot
[  1%] Built target nls
[  2%] Generating lv_math_orc.h
[  3%] Generating lv_alpha_blend_orc.h
Scanning dependencies of target libvisual
[  4%] Building C object libvisual/CMakeFiles/libvisual.dir/lv_mem.c.o
[  5%] Building C object libvisual/CMakeFiles/libvisual.dir/lv_log.c.o
[  6%] Building C object libvisual/CMakeFiles/libvisual.dir/lv_param_value.c.o
[  7%] Building C object libvisual/CMakeFiles/libvisual.dir/lv_param_validators.c.o
[  8%] Building C object libvisual/CMakeFiles/libvisual.dir/lv_cpu.c.o
[  9%] Building C object libvisual/CMakeFiles/libvisual.dir/lv_error.c.o
[ 10%] Building C object libvisual/CMakeFiles/libvisual.dir/lv_math.c.o
[ 12%] Building C object libvisual/CMakeFiles/libvisual.dir/lv_gl.c.o
[ 13%] Building C object libvisual/CMakeFiles/libvisual.dir/lv_alpha_blend.c.o
[ 14%] Building C object libvisual/CMakeFiles/libvisual.dir/lv_util.c.o
[ 15%] Building CXX object libvisual/CMakeFiles/libvisual.dir/lv_actor.cpp.o
[ 16%] Building CXX object libvisual/CMakeFiles/libvisual.dir/lv_audio.cpp.o
[ 17%] Building CXX object libvisual/CMakeFiles/libvisual.dir/lv_bin.cpp.o
In file included from /tmp/tmp.vTxvBVK0Oe/libvisual/libvisual/libvisual/lv_bin.h:28,
                 from /tmp/tmp.vTxvBVK0Oe/libvisual/libvisual/libvisual/lv_bin.cpp:25:
/tmp/tmp.vTxvBVK0Oe/libvisual/libvisual/libvisual/lv_input.h:84:31: error: ‘std::function’ has not been declared
       void set_callback (std::function<bool (Audio&)> const& callback);
                               ^~~~~~~~
/tmp/tmp.vTxvBVK0Oe/libvisual/libvisual/libvisual/lv_input.h:84:39: error: expected ‘,’ or ‘...’ before ‘<’ token
       void set_callback (std::function<bool (Audio&)> const& callback);
                                       ^
make[2]: *** [libvisual/CMakeFiles/libvisual.dir/build.make:227: libvisual/CMakeFiles/libvisual.dir/lv_bin.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:650: libvisual/CMakeFiles/libvisual.dir/all] Error 2
make: *** [Makefile:152: all] Error 2