lftp
lftp copied to clipboard
Build failure when compiler is in C++14 or earlier mode
lftp 4.9.3 fails to build on old compilers:
In file included from Torrent.cc:32:
../lib/dirent.h:100:36: error: expected ','
&& DT_SOCK != DT_WHT);
^
This is the end of a static_assert:
static_assert (DT_UNKNOWN != DT_FIFO && DT_UNKNOWN != DT_CHR
&& DT_UNKNOWN != DT_BLK && DT_UNKNOWN != DT_REG
&& DT_UNKNOWN != DT_LNK && DT_UNKNOWN != DT_SOCK
&& DT_UNKNOWN != DT_WHT
&& DT_FIFO != DT_CHR && DT_FIFO != DT_BLK && DT_FIFO != DT_REG
&& DT_FIFO != DT_LNK && DT_FIFO != DT_SOCK && DT_FIFO != DT_WHT
&& DT_CHR != DT_BLK && DT_CHR != DT_REG && DT_CHR != DT_LNK
&& DT_CHR != DT_SOCK && DT_CHR != DT_WHT
&& DT_BLK != DT_REG && DT_BLK != DT_LNK && DT_BLK != DT_SOCK
&& DT_BLK != DT_WHT
&& DT_REG != DT_LNK && DT_REG != DT_SOCK && DT_REG != DT_WHT
&& DT_LNK != DT_SOCK && DT_LNK != DT_WHT
&& DT_SOCK != DT_WHT);
From what I can tell, when static_assert was introduced in C++11, it required a second (string) parameter. In C++17 the second parameter became optional.
I reported this to MacPorts here: https://trac.macports.org/ticket/72993
Note: the configure test for static_assert fails, even on much newer compilers.
checking for static_assert... no
This is what's in config.log on a newer machine with a newer compiler that is able to compile lftp:
configure:51389: checking for static_assert
configure:51427: ccache /usr/bin/clang -c -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -arch x86_64 -Wall -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk conftest.c >&5
conftest.c:220:30: error: expected parameter declarator
static_assert (2 + 2 == 4, "arithmetic does not work");
^
conftest.c:220:30: error: expected ')'
conftest.c:220:29: note: to match this '('
static_assert (2 + 2 == 4, "arithmetic does not work");
^
conftest.c:220:15: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
static_assert (2 + 2 == 4, "arithmetic does not work");
^
conftest.c:221:30: error: expected parameter declarator
static_assert (2 + 2 == 4);
^
conftest.c:221:30: error: expected ')'
conftest.c:221:29: note: to match this '('
static_assert (2 + 2 == 4);
^
conftest.c:221:15: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
static_assert (2 + 2 == 4);
^
2 warnings and 4 errors generated.
configure:51427: $? = 1
configure:51427: ccache /usr/bin/clang -c -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -arch x86_64 -Wall -DINCLUDE_ASSERT_H -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk conftest.c >&5
conftest.c:221:40: error: static_assert with no message is a C++17 extension [-Werror,-Wc++17-extensions]
static_assert (2 + 2 == 4);
^
, ""
conftest.c:228:48: error: static_assert with no message is a C++17 extension [-Werror,-Wc++17-extensions]
static_assert (sizeof (char) == 1);
^
, ""
2 errors generated.
configure:51427: $? = 1
It's weird that you're checking for static_assert, determining that it doesn't exist or doesn't work, but are then using it anyway.