smartnode / telebot

Telegram Bot API in C
https://elmurod.net/telebot
Apache License 2.0
159 stars 35 forks source link

run makefile console error in Centos 7.8 #45

Closed rjzou closed 3 years ago

rjzou commented 3 years ago

/www/wwwroot/telebot/src/telebot-parser.c: In function ‘telebot_parser_get_photos’: /www/wwwroot/telebot/src/telebot-parser.c:881:5: error: ‘for’ loop initial declarations are only allowed in C99 mode for (int index = 0; index < array_len; index++) ^ /www/wwwroot/telebot/src/telebot-parser.c: In function ‘telebot_parser_get_poll_answer’: /www/wwwroot/telebot/src/telebot-parser.c:1447:5: error: ‘for’ loop initial declarations are only allowed in C99 mode for (int index = 0; index < answer->count_option_ids; index++) ^ /www/wwwroot/telebot/src/telebot-parser.c: In function ‘telebot_parser_get_poll’: /www/wwwroot/telebot/src/telebot-parser.c:1578:5: error: ‘for’ loop initial declarations are only allowed in C99 mode for (int index = 0; index < poll->count_options; index++) ^ /www/wwwroot/telebot/src/telebot-parser.c: In function ‘telebot_parser_get_user_profile_photos’: /www/wwwroot/telebot/src/telebot-parser.c:1624:5: error: ‘for’ loop initial declarations are only allowed in C99 mode for (int i = 0; i < 4; i++) ^ /www/wwwroot/telebot/src/telebot-parser.c:1629:14: error: redefinition of ‘i’ for (int i = 0; i < total; i++) ^ /www/wwwroot/telebot/src/telebot-parser.c:1624:14: note: previous definition of ‘i’ was here for (int i = 0; i < 4; i++) ^ /www/wwwroot/telebot/src/telebot-parser.c:1629:5: error: ‘for’ loop initial declarations are only allowed in C99 mode for (int i = 0; i < total; i++) ^ /www/wwwroot/telebot/src/telebot-parser.c:1635:9: error: ‘for’ loop initial declarations are only allowed in C99 mode for (int j = 0; j < subtotal; j++) ^ /www/wwwroot/telebot/src/telebot-parser.c:1644:9: error: ‘for’ loop initial declarations are only allowed in C99 mode for (int i = 0; i < 4; i++) ^ make[3]: [CMakeFiles/telebot.dir/src/telebot-parser.c.o] Error 1 make[2]: [CMakeFiles/telebot.dir/all] Error 2 make[1]: [test/CMakeFiles/echobot.dir/rule] Error 2 make: [echobot] Error 2

rjzou commented 3 years ago

cmake version 3.20.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).

rjzou commented 3 years ago

GNU Make 3.82 Built for x86_64-redhat-linux-gnu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

smartnode commented 3 years ago

Add -std=c99 compiler option in CMakeLists.txt and build again. As below :

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS} -Werror -Wall -Wno-unused-function -std=c99" )