问题描述:
编译qsdk出现error: 'for' loop initial declarations are only allowed in C99 mode错误
Log信息:
mtune=cortex-a7 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=soft -Wl,-z,now -Wl,-z,relro -Wall -W -Wshadow -pedantic -MT mod_vhostdb.lo -MD -MP -MF .deps/mod_vhostdb.Tpo -c mod_vhostdb.c -fPIC -DPIC -o .libs/mod_vhostdb.o
mod_vhostdb.c: In function 'mod_vhostdb_set_defaults':
mod_vhostdb.c:69:5: error: 'for' loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < srv->config_context->used; ++i) {
^
mod_vhostdb.c:69:5: note: use option -std=c99 or -std=gnu99 to compile your code
mod_vhostdb.c: In function 'mod_vhostdb_patch_connection':
mod_vhostdb.c:104:5: error: 'for' loop initial declarations are only allowed in C99 mode
for (size_t i = 1; i < srv->config_context->used; ++i) {
^
mod_vhostdb.c:112:9: error: 'for' loop initial declarations are only allowed in C99 mode
for (size_t j = 0; j < dc->value->used; ++j) {
^
Makefile:1947: recipe for target 'mod_vhostdb.lo' failed
make[6]: *** [mod_vhostdb.lo] Error 1
make[6]: Leaving directory '/home/wellnw/qsdk53/build_dir/target-arm_cortex-a7_uClibc-1.0.14_eabi/lighttpd-1.4.48/src'
Makefile:1426: recipe for target 'all' failed
make[5]: *** [all] Error 2
make[5]: Leaving directory '/home/wellnw/qsdk53/build_dir/target-arm_cortex-a7_uClibc-1.0.14_eabi/lighttpd-1.4.48/src'
Makefile:447: recipe for target 'all-recursive' failed
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory '/home/wellnw/qsdk53/build_dir/target-arm_cortex-a7_uClibc-1.0.14_eabi/lighttpd-1.4.48'
Makefile:377: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/home/wellnw/qsdk53/build_dir/target-arm_cortex-a7_uClibc-1.0.14_eabi/lighttpd-1.4.48'
Makefile:197: recipe for target '/home/wellnw/qsdk53/build_dir/target-arm_cortex-a7_uClibc-1.0.14_eabi/lighttpd-1.4.48/.built' failed
make[2]: *** [/home/wellnw/qsdk53/build_dir/target-arm_cortex-a7_uClibc-1.0.14_eabi/lighttpd-1.4.48/.built] Error 2
make[2]: Leaving directory '/home/wellnw/qsdk53/feeds/gli_pub/lighttpd'
package/Makefile:191: recipe for target 'package/feeds/gli_pub/lighttpd/compile' failed
make[1]: *** [package/feeds/gli_pub/lighttpd/compile] Error 2
make[1]: Leaving directory '/home/wellnw/qsdk53'
/home/wellnw/qsdk53/include/toplevel.mk:186: recipe for target 'package/feeds/gli_pub/lighttpd/compile' failed
make: *** [package/feeds/gli_pub/lighttpd/compile] Error 2
解决方案:
找到 package/feeds/gli_pub/lighttpd/Makefile 文件,在Makefile开头增加以下内容即可
TARGET_CFLAGS += -std=gnu99