Annotate as extern "C" when included in C++ files to prevent issues due
to conflicting linkage - C vs C++. With follow up commits we'll remove
the "extern "C" { #include "header.h" } pattern which we currently use.Conditionally including system headers (either directly or not) in such a construct in a bad idea as they might include C++ symbols. Signed-off-by: Emil Velikov <[email protected]> --- src/waffle/api/api_object.h | 8 ++++++++ src/waffle/core/wcore_config.h | 8 ++++++++ src/waffle/core/wcore_config_attrs.h | 8 ++++++++ src/waffle/core/wcore_display.h | 8 ++++++++ src/waffle/core/wcore_error.h | 8 ++++++++ src/waffle/core/wcore_util.h | 8 ++++++++ 6 files changed, 48 insertions(+) diff --git a/src/waffle/api/api_object.h b/src/waffle/api/api_object.h index d417d0a..ef11c5b 100644 --- a/src/waffle/api/api_object.h +++ b/src/waffle/api/api_object.h @@ -27,6 +27,10 @@ #include "waffle.h" +#ifdef __cplusplus +extern "C" { +#endif + // This header is so sad and lonely... but there is no other appropriate place // to define this struct. @@ -36,3 +40,7 @@ struct api_object { /// For consistency, a `waffle_display` belongs to itself. size_t display_id; }; + +#ifdef __cplusplus +} +#endif diff --git a/src/waffle/core/wcore_config.h b/src/waffle/core/wcore_config.h index 27534af..2fc02d5 100644 --- a/src/waffle/core/wcore_config.h +++ b/src/waffle/core/wcore_config.h @@ -36,6 +36,10 @@ #include "wcore_config_attrs.h" #include "wcore_util.h" +#ifdef __cplusplus +extern "C" { +#endif + struct wcore_config; union waffle_native_config; @@ -77,3 +81,7 @@ wcore_config_teardown(struct wcore_config *self) assert(self); return true; } + +#ifdef __cplusplus +} +#endif diff --git a/src/waffle/core/wcore_config_attrs.h b/src/waffle/core/wcore_config_attrs.h index 0eaa4a1..cca5e8b 100644 --- a/src/waffle/core/wcore_config_attrs.h +++ b/src/waffle/core/wcore_config_attrs.h @@ -28,6 +28,10 @@ #include <stdbool.h> #include <stdint.h> +#ifdef __cplusplus +extern "C" { +#endif + /// @brief Encodes the attribute list received by waffle_config_choose(). struct wcore_config_attrs { int32_t context_api; @@ -84,3 +88,7 @@ bool wcore_config_attrs_version_le( const struct wcore_config_attrs *attrs, int merged_version); + +#ifdef __cplusplus +} +#endif diff --git a/src/waffle/core/wcore_display.h b/src/waffle/core/wcore_display.h index de6ca5e..53f7d08 100644 --- a/src/waffle/core/wcore_display.h +++ b/src/waffle/core/wcore_display.h @@ -32,6 +32,10 @@ #include "wcore_util.h" +#ifdef __cplusplus +extern "C" { +#endif + struct wcore_display; struct wcore_platform; union waffle_native_display; @@ -63,3 +67,7 @@ wcore_display_teardown(struct wcore_display *self) assert(self); return true; } + +#ifdef __cplusplus +} +#endif diff --git a/src/waffle/core/wcore_error.h b/src/waffle/core/wcore_error.h index 0a9767c..cee5bd1 100644 --- a/src/waffle/core/wcore_error.h +++ b/src/waffle/core/wcore_error.h @@ -29,6 +29,10 @@ #include "waffle.h" +#ifdef __cplusplus +extern "C" { +#endif + /// @brief Thread-local info for the wcore_error module. struct wcore_error_tinfo; @@ -92,3 +96,7 @@ _wcore_error_internal(const char *file, int line, const char *format, ...); void _wcore_error_enable(void); void _wcore_error_disable(void); + +#ifdef __cplusplus +} +#endif diff --git a/src/waffle/core/wcore_util.h b/src/waffle/core/wcore_util.h index 183134f..b823b21 100644 --- a/src/waffle/core/wcore_util.h +++ b/src/waffle/core/wcore_util.h @@ -28,6 +28,10 @@ #include <stddef.h> #include "c99_compat.h" +#ifdef __cplusplus +extern "C" { +#endif + #define container_of(ptr, type, member) ({ \ const __typeof__(((type *)0)->member ) *__mptr = (ptr); \ (type*)((void*)__mptr - offsetof(type, member)); \ @@ -107,3 +111,7 @@ wcore_calloc(size_t size); const char* wcore_enum_to_string(int32_t e); + +#ifdef __cplusplus +} +#endif -- 2.3.1 _______________________________________________ waffle mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/waffle

