-
Problem report
-
Resolution: Unresolved
-
Trivial
-
None
-
6.4.0beta5
-
None
-
NetBSD 7.1, gcc 4.8.5 with NetBSD patches
Albeit on a slightly old version of NetBSD, the compiler, by default, isn't invoked in C99 mode, and thus fails to recognize valid C99 constructs.
Specifically for this case, it fails to compile the dbconfig.c module in the zbxcacheconfig library:
Making all in zbxcacheconfig dbconfig.c: In function 'dc_preproc_sync_preprocitem': dbconfig.c:9404:2: error: 'for' loop initial declarations are only allowed in C99 mode for (int i = 0; i < preprocitem->preproc_ops.values_num; i++) ^ dbconfig.c:9404:2: note: use option -std=c99 or -std=gnu99 to compile your code dbconfig.c: In function 'dc_preproc_sync_masteritem': dbconfig.c:9428:2: error: 'for' loop initial declarations are only allowed in C99 mode for (int i = 0; i < masteritem->dep_itemids.values_num; i++) ^ dbconfig.c: In function 'dc_preproc_compare': dbconfig.c:9465:2: error: 'for' loop initial declarations are only allowed in C99 mode for (int i = 0; i < pp1->steps_num; i++) ^ dbconfig.c: In function 'dc_preproc_sync_item': dbconfig.c:9515:2: error: 'for' loop initial declarations are only allowed in C99 mode for (int i = 0; i < preproc->steps_num; i++) ^ --- libzbxcacheconfig_a-dbconfig.o --- *** [libzbxcacheconfig_a-dbconfig.o] Error code 1 make[3]: stopped in /home/jxl/zabbix/src/libs/zbxcacheconfig 1 error make[3]: stopped in /home/jxl/zabbix/src/libs/zbxcacheconfig --- all-recursive --- *** [all-recursive] Error code 1 make[2]: stopped in /home/jxl/zabbix/src/libs 1 error make[2]: stopped in /home/jxl/zabbix/src/libs --- all-recursive --- *** [all-recursive] Error code 1 make[1]: stopped in /home/jxl/zabbix/src 1 error make[1]: stopped in /home/jxl/zabbix/src --- all-recursive --- *** [all-recursive] Error code 1 make: stopped in /home/jxl/zabbix 1 error make: stopped in /home/jxl/zabbix
The offender here are foor loops that declare a local counter in the initialization portion, which is neat, but imho, a bit early, as configure tests don't even pass in C99 mode. (I want to address the tests in the near future as well)
Not sure if we want to use the construct, however, as the code base is pretty fit for a pre-C99 compiler, and this just breaks our ability to build in compliance modes before that.