diff --git a/examples/hello_world/hello_world.c b/examples/hello_world/hello_world.c index f4925bf674e..9b49d96e06e 100644 --- a/examples/hello_world/hello_world.c +++ b/examples/hello_world/hello_world.c @@ -17,7 +17,9 @@ * limitations under the License. */ -#include +#include +#include +#include int main() { diff --git a/examples/out_lib/out_lib.c b/examples/out_lib/out_lib.c index ada207b0c4f..fab39e18cde 100644 --- a/examples/out_lib/out_lib.c +++ b/examples/out_lib/out_lib.c @@ -17,7 +17,9 @@ * limitations under the License. */ -#include +#include +#include +#include #include int my_stdout_json(void *record, size_t size, void *data) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 38f1b0dccd5..075198a724c 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,5 +1,5 @@ # Install fluent-bit headers -install(FILES "fluent-bit.h" +install(FILES "fluent-bit.h" "fluent-bit-minimal.h" DESTINATION ${FLB_INSTALL_INCLUDEDIR} COMPONENT headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) diff --git a/include/fluent-bit-minimal.h b/include/fluent-bit-minimal.h new file mode 100644 index 00000000000..463f6c2038a --- /dev/null +++ b/include/fluent-bit-minimal.h @@ -0,0 +1,33 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2022 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLUENT_BIT_MINIMAL_H +#define FLUENT_BIT_MINIMAL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/fluent-bit/flb_lib.h b/include/fluent-bit/flb_lib.h index b5383dace3f..38d50b38dfa 100644 --- a/include/fluent-bit/flb_lib.h +++ b/include/fluent-bit/flb_lib.h @@ -20,8 +20,32 @@ #ifndef FLB_LIB_H #define FLB_LIB_H -#include -#include +/* Avoid dependencies for library users who just want the public API */ +#ifdef FLUENT_BIT_MINIMAL_H + #include + + struct mk_event_loop; + struct mk_event; + struct flb_config; + struct flb_cf; + + /* Copied from mk_macros.h */ + #ifdef __GNUC__ + #if __GNUC__ >= 4 + #define FLB_EXPORT __attribute__ ((visibility ("default"))) + #else + #define FLB_EXPORT + #endif + #elif defined(_WIN32) + #define FLB_EXPORT __declspec(dllexport) + /* mk_macros doesn't have an 'else'... seems like an oversight */ + #else + #define FLB_EXPORT extern + #endif +#else + #include + #include +#endif /* Lib engine status */ #define FLB_LIB_ERROR -1 diff --git a/tests/runtime/in_event_test.c b/tests/runtime/in_event_test.c index 1169d8fd821..773723c8c02 100644 --- a/tests/runtime/in_event_test.c +++ b/tests/runtime/in_event_test.c @@ -1,6 +1,6 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#include +#include #include "flb_tests_runtime.h" void flb_test_input_event()