1
0
mirror of https://github.com/fumiama/CMoe-Counter.git synced 2024-09-23 19:08:24 +02:00

fix(compile): 'for' loop initial declarations are only allowed in C99 mode

This commit is contained in:
源文雨 2024-04-12 23:04:33 +09:00
parent 538e120d45
commit d3385953db
2 changed files with 5 additions and 9 deletions

View File

@ -5,12 +5,6 @@ SET(CMAKE_BUILD_TYPE "Release")
include_directories("/usr/local/include")
link_directories("/usr/local/lib")
if (NOT BUILD STREQUAL "docker")
#c99
add_compile_options(-std=c99)
message(STATUS "optional:-std=c99")
endif ()
add_executable(cmoe cmoe.c)
add_executable(cmoeditor editor.c)

8
cmoe.c
View File

@ -83,7 +83,8 @@ static inline int add_user(char* name, uint32_t count, FILE* fp) {
static inline uint32_t get_content_len(int isbig, uint16_t* len_type, char* cntstr) {
uint32_t len = sizeof(svg_small) // small & big has the same len
+ sizeof(svg_tail) - 1;
for (int i = 0; cntstr[i]; i++) {
int i = 0;
for (; cntstr[i]; i++) {
len += len_type[cntstr[i] - '0'] + (sizeof(img_slot_front) + sizeof(img_slot_rear) - 2);
if (i > 0) len++;
if (i > 2-isbig) len++;
@ -111,7 +112,8 @@ static void return_count(FILE* fp, char* name, char* theme) {
char cntstrbuf[11];
sprintf(cntstrbuf, "%010u", d->count);
char* cntstr = cntstrbuf;
for (int i = 0; i < 10; i++) if (cntstrbuf[i] != '0') {
int i = 0;
for (; i < 10; i++) if (cntstrbuf[i] != '0') {
if (i > 2) cntstr = cntstrbuf+i-2;
break;
}
@ -143,7 +145,7 @@ static void return_count(FILE* fp, char* name, char* theme) {
return;
}
printf(head, w*(10+cntstrbuf-cntstr));
for (int i = 0; cntstr[i]; i++) {
for (i = 0; cntstr[i]; i++) {
printf(img_slot_front, w * i, w, h);
int n = cntstr[i] - '0';
fwrite(theme_type[n], len_type[n], 1, stdout);