0

Fluent-bit is compiled under linux (Ubuntu 24.04 LTS) from source (tag v3.2.2) Using a C-compiler (gcc) test program compiles fine Using g++ I get compile errors from mpack.h complaining about conflicting declarations (see example below)

This my simple program:

#include <fluent-bit.h>
#include <fluent-bit/flb_sds.h>

void flb_test_line_format() {
    flb_ctx_t* ctx;
    /* Create context */
    ctx = flb_create();
    flb_service_set(ctx, "flush", "1", "grace", "1", "log_level", "error", NULL);
}

int main() {
    return 0;
}

This is part of the reported errors from g++:

In file included from /home/pbc/fluent-bit/lib/ctraces/include/ctraces/ctraces.h:31,
                 from /home/pbc/fluent-bit/include/fluent-bit/flb_input_trace.h:24,
                 from /home/pbc/fluent-bit/include/fluent-bit/flb_input.h:41,
                 from /home/pbc/fluent-bit/include/fluent-bit/flb_engine.h:25,
                 from /home/pbc/fluent-bit/include/fluent-bit/flb_output.h:38:
/home/pbc/fluent-bit/lib/mpack-amalgamation-1.1.1/src/mpack/mpack.h: At global scope:
/home/pbc/fluent-bit/lib/mpack-amalgamation-1.1.1/src/mpack/mpack.h:4206:19: error: conflicting declaration of C function ‘void mpack_write(mpack_writer_t*, int16_t)’
 4206 | MPACK_INLINE void mpack_write(mpack_writer_t* writer, int16_t value) {
      |                   ^~~~~~~~~~~
/home/pbc/fluent-bit/lib/mpack-amalgamation-1.1.1/src/mpack/mpack.h:4202:19: note: previous declaration ‘void mpack_write(mpack_writer_t*, int8_t)’
 4202 | MPACK_INLINE void mpack_write(mpack_writer_t* writer, int8_t value) {

mpack.h wants to overload functions which is allowed with g++, but it seems this is run with extern "C" although the extern "C" is ended immediately above the overloaded functions.

What am I missing here?

All headers are included from the fluent-bit repository the same way as the c-files in tests/runtime are compiled (tested with make VERBOSE=1)

3
  • I would open an issue on the GitHub project. Commented Dec 17, 2024 at 18:19
  • Thx, have done so Commented Dec 18, 2024 at 7:05
  • @pptaszni extern "C" is declared in fluent-bit.h for all header files which would mean mpack.h is also within extern "C". Nested extern "C" within mpack.h could be the issue. I would expect extern "C" declarations would only be within individual header files, not for the inclution of another header file Commented Dec 18, 2024 at 7:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.