Skip to content

mpack compilation error on CentOS 6 #69

@edsiper

Description

@edsiper

mpack is a great library and we started the first integration here:

fluent/fluent-bit@3886c22

However, we got some build problems on a certain compiler version (gcc on centos 6):

/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c: In function ‘mpack_str_check_no_null’:
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c:847: error: ‘for’ loop initial declarations are only allowed in C99 mode
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c:847: note: use option -std=c99 or -std=gnu99 to compile your code
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c: In function ‘mpack_expect_enum’:
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c:4017: error: ‘for’ loop initial declarations are only allowed in C99 mode
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c: In function ‘mpack_expect_enum_optional’:
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c:4050: error: ‘for’ loop initial declarations are only allowed in C99 mode
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c: In function ‘mpack_node_map_int_impl’:
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c:5827: error: ‘for’ loop initial declarations are only allowed in C99 mode
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c: In function ‘mpack_node_map_uint_impl’:
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c:5858: error: ‘for’ loop initial declarations are only allowed in C99 mode
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c: In function ‘mpack_node_map_str_impl’:
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c:5892: error: ‘for’ loop initial declarations are only allowed in C99 mode
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c: In function ‘mpack_node_enum_optional’:
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.c:5994: error: ‘for’ loop initial declarations are only allowed in C99 mode

this is not a new report, indeed there are previous issues reported on mpack repo:

we can get rid of the problem defining CFLAGS with -std=c99, anyways I see other warnings remain:

/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.h:1218: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.h:1240: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.h:2274: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.h:2292: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.h:3237: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.h:3388: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.h:4314: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.h:4332: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.h:5734: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.h:5753: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
/root/fluent-bit/lib/mpack-amalgamation-1.0/src/mpack/mpack.h:7145: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’

what would be the suggested flags to get rid of warnings ? or can you set the variables on top of the functions ?, looks like a small change that will help to build it on old systems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions