HAProxy is documented to support gcc >= 3.4 as per INSTALL file, however hlua.c makes use of c11 only loop initial declarations leading to build failure when using gcc-4.9.4:
x86_64-unknown-linux-gnu-gcc -Iinclude -Wchar-subscripts -Wcomment -Wformat -Winit-self -Wmain -Wmissing-braces -Wno-pragmas -Wparentheses -Wreturn-type -Wsequence-point -Wstrict-aliasing -Wswitch -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused-label -Wunused-variable -Wunused-value -Wpointer-sign -Wimplicit -pthread -fdiagnostics-color=auto -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3 -msse -mfpmath=sse -march=core2 -g -fPIC -g -Wall -Wextra -Wundef -Wdeclaration-after-statement -fwrapv -Wno-unused-label -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wno-missing-field-initializers -Wtype-limits -DUSE_EPOLL -DUSE_NETFILTER -DUSE_PCRE2 -DUSE_PCRE2_JIT -DUSE_POLL -DUSE_THREAD -DUSE_BACKTRACE -DUSE_TPROXY -DUSE_LINUX_TPROXY -DUSE_LINUX_SPLICE -DUSE_LIBCRYPT -DUSE_CRYPT_H -DUSE_GETADDRINFO -DUSE_OPENSSL -DUSE_LUA -DUSE_ACCEPT4 -DUSE_SLZ -DUSE_CPU_AFFINITY -DUSE_TFO -DUSE_NS -DUSE_DL -DUSE_RT -DUSE_PRCTL -DUSE_THREAD_DUMP -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -I/usr/local/include -DCONFIG_HAPROXY_VERSION=\"2.5.0\" -DCONFIG_HAPROXY_DATE=\"2021/11/23\" -c -o src/connection.o src/connection.c src/hlua.c: In function 'hlua_config_prepend_path': src/hlua.c:11292:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode for (size_t i = 0; i < 2; i++) { ^ src/hlua.c:11292:2: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code This commit moves loop iterator to an explicit declaration. No backport needed as this issue was introduced in v2.5-dev10~69 with commit 9e5e586e35c5 ("BUG/MINOR: lua: Fix lua error handling in `hlua_config_prepend_path()`") --- src/hlua.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hlua.c b/src/hlua.c index 08735374af77..8dea91e75832 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -11249,6 +11249,7 @@ static int hlua_config_prepend_path(char **args, int section_type, struct proxy char *path; char *type = "path"; struct prepend_path *p = NULL; + size_t i; if (too_many_args(2, args, err, NULL)) { goto err; @@ -11289,7 +11290,7 @@ static int hlua_config_prepend_path(char **args, int section_type, struct proxy * thread. The remaining threads will be initialized based on * prepend_path_list. */ - for (size_t i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) { lua_State *L = hlua_states[i]; const char *error;