[BUG] Build still uses C++11 flags, although C++14 is supposed to be required
LeSpocky opened this issue · 1 comments
LeSpocky commented
Prerequisites
- Put an X between the brackets on this line if you have checked that your issue isn't already filed: https://github.com/search?l=&q=repo%3Aetr%2Flibhttpserver&type=Issues
Description
Changeset 1e61eae added -std=c++11 to CXXFLAGS unconditionally, which is still in configure.ac, leading to this output:
% make :(
make all-recursive
make[1]: Verzeichnis „/mnt/data/adahl/src/libhttpserver/build“ wird betreten
Making all in src
make[2]: Verzeichnis „/mnt/data/adahl/src/libhttpserver/build/src“ wird betreten
/bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../src -I.. -I../ -I../../src/httpserver/ -DDEBUG -g -Wall -Wextra -Werror -pedantic -std=c++14 -Wno-unused-command-line-argument -O0 -fPIC -Wall -DUSE_FASTOPEN -std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT -MT libhttpserver_la-string_utilities.lo -MD -MP -MF .deps/libhttpserver_la-string_utilities.Tpo -c -o libhttpserver_la-string_utilities.lo `test -f 'string_utilities.cpp' || echo '../../src/'`string_utilities.cpp
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../src -I.. -I../ -I../../src/httpserver/ -DDEBUG -g -Wall -Wextra -Werror -pedantic -std=c++14 -Wno-unused-command-line-argument -O0 -fPIC -Wall -DUSE_FASTOPEN -std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT -MT libhttpserver_la-string_utilities.lo -MD -MP -MF .deps/libhttpserver_la-string_utilities.Tpo -c ../../src/string_utilities.cpp -fPIC -DPIC -o .libs/libhttpserver_la-string_utilities.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../src -I.. -I../ -I../../src/httpserver/ -DDEBUG -g -Wall -Wextra -Werror -pedantic -std=c++14 -Wno-unused-command-line-argument -O0 -fPIC -Wall -DUSE_FASTOPEN -std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT -MT libhttpserver_la-string_utilities.lo -MD -MP -MF .deps/libhttpserver_la-string_utilities.Tpo -c ../../src/string_utilities.cpp -o libhttpserver_la-string_utilities.o >/dev/null 2>&1
mv -f .deps/libhttpserver_la-string_utilities.Tpo .deps/libhttpserver_la-string_utilities.Plo
/bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../src -I.. -I../ -I../../src/httpserver/ -DDEBUG -g -Wall -Wextra -Werror -pedantic -std=c++14 -Wno-unused-command-line-argument -O0 -fPIC -Wall -DUSE_FASTOPEN -std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT -MT libhttpserver_la-webserver.lo -MD -MP -MF .deps/libhttpserver_la-webserver.Tpo -c -o libhttpserver_la-webserver.lo `test -f 'webserver.cpp' || echo '../../src/'`webserver.cpp
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../src -I.. -I../ -I../../src/httpserver/ -DDEBUG -g -Wall -Wextra -Werror -pedantic -std=c++14 -Wno-unused-command-line-argument -O0 -fPIC -Wall -DUSE_FASTOPEN -std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT -MT libhttpserver_la-webserver.lo -MD -MP -MF .deps/libhttpserver_la-webserver.Tpo -c ../../src/webserver.cpp -fPIC -DPIC -o .libs/libhttpserver_la-webserver.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../src -I.. -I../ -I../../src/httpserver/ -DDEBUG -g -Wall -Wextra -Werror -pedantic -std=c++14 -Wno-unused-command-line-argument -O0 -fPIC -Wall -DUSE_FASTOPEN -std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT -MT libhttpserver_la-webserver.lo -MD -MP -MF .deps/libhttpserver_la-webserver.Tpo -c ../../src/webserver.cpp -o libhttpserver_la-webserver.o >/dev/null 2>&1
mv -f .deps/libhttpserver_la-webserver.Tpo .deps/libhttpserver_la-webserver.Plo
…
Notice those lines have -std=c++14 first and -std=c++11 later, it builds successfully though.
This actually bit me when I added the example from #229 to the examples folder and tried to build it, build fails like this then:
g++ -DHAVE_CONFIG_H -I. -I../../examples -I.. -I../../src -I../../src/httpserver/ -DDEBUG -g -Wall -Wextra -Werror -pedantic -std=c++14 -Wno-unused-command-line-argument -O0 -DUSE_FASTOPEN -std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT -MT bug_229.o -MD -MP -MF $depbase.Tpo -c -o bug_229.o ../../examples/bug_229.cpp &&\
mv -f $depbase.Tpo $depbase.Po
../../examples/bug_229.cpp: In member function ‘virtual const std::shared_ptr<httpserver::http_response> file_resource::render_POST(const httpserver::http_request&)’:
../../examples/bug_229.cpp:13:58: error: use of ‘auto’ in lambda parameter declaration only available with -std=c++14 or -std=gnu++14
std::for_each(headers.begin(), headers.end(), [](auto& p){
^~~~
../../examples/bug_229.cpp: In lambda function:
../../examples/bug_229.cpp:14:32: error: request for member ‘first’ in ‘p’, which is of non-class type ‘int’
std::cout << p.first << " -> " << p.second << std::endl;
^~~~~
../../examples/bug_229.cpp:14:53: error: request for member ‘second’ in ‘p’, which is of non-class type ‘int’
std::cout << p.first << " -> " << p.second << std::endl;
^~~~~~
../../examples/bug_229.cpp: In member function ‘virtual const std::shared_ptr<httpserver::http_response> file_resource::render_POST(const httpserver::http_request&)’:
../../examples/bug_229.cpp:19:52: error: use of ‘auto’ in lambda parameter declaration only available with -std=c++14 or -std=gnu++14
std::for_each(args.begin(), args.end(), [](auto& p) {
^~~~
../../examples/bug_229.cpp: In lambda function:
../../examples/bug_229.cpp:20:32: error: request for member ‘first’ in ‘p’, which is of non-class type ‘int’
std::cout << p.first << " -> " << p.second << std::endl;
^~~~~
../../examples/bug_229.cpp:20:53: error: request for member ‘second’ in ‘p’, which is of non-class type ‘int’
std::cout << p.first << " -> " << p.second << std::endl;
^~~~~~
…
Steps to Reproduce
- Create a new file in subfolder examples
- Copy and paste the example code from #229 to that new file
- Adapt examples/Makefile.am to build that new source file
- Call ./configure with --enable-examples
- Call make
Expected behavior: Build does not fail.
Actual behavior: Build fails.
Reproduces how often: Always.
Versions
- OS version: Debian GNU/Linux 10 (buster)
- libhttpserver version: 0.18.2-23-g8901082 (current master)
- libmicrohttpd version: 0.9.62-1 (Debian package)
If you have problems during build:
- Compiler version: g++ (Debian 8.3.0-6) 8.3.0
- autotools version: autoconf (GNU Autoconf) 2.69, automake (GNU automake) 1.16.1
Additional Information
C++14 support is required since #227 was merged.
I have no experience with autotools and can not provide a fix by myself.
etr commented
Fix in head.