From 9af7ca10841504e335883099719abab03ff6f77d Mon Sep 17 00:00:00 2001 From: Kevin Pyle Date: Wed, 25 Apr 2012 22:37:03 -0500 Subject: [PATCH] Mark library functions as "C" linkage The documentation disclaims support for building with a C++ compiler, so it is reasonable to assume that the library will be built with a plain C compiler, so the functions will all have plain C linkage. By default, a C++ application that wished to use libiniparser would need to wrap the inclusion of libiniparser headers in 'extern "C" { ... }' to reflect the C linkage of libiniparser. Instead, place that marker directly in the libiniparser headers, so that client applications do not need to care. This has no effect on normal compilation of libiniparser, since the new markers are inside a '#ifdef __cplusplus' guard, and straight C compilers do not define __cplusplus. --- src/dictionary.h | 8 ++++++++ src/iniparser.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/dictionary.h b/src/dictionary.h index 34c4b82..7870316 100644 --- a/src/dictionary.h +++ b/src/dictionary.h @@ -23,6 +23,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + /*--------------------------------------------------------------------------- New types ---------------------------------------------------------------------------*/ @@ -162,4 +166,8 @@ void dictionary_unset(dictionary * d, const char * key); /*--------------------------------------------------------------------------*/ void dictionary_dump(dictionary * d, FILE * out); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/iniparser.h b/src/iniparser.h index ecd73bf..153ad07 100644 --- a/src/iniparser.h +++ b/src/iniparser.h @@ -27,6 +27,10 @@ #include "dictionary.h" +#ifdef __cplusplus +extern "C" { +#endif + /*-------------------------------------------------------------------------*/ /** @brief Get number of sections in a dictionary @@ -304,4 +308,8 @@ dictionary * iniparser_load(const char * ininame); /*--------------------------------------------------------------------------*/ void iniparser_freedict(dictionary * d); +#ifdef __cplusplus +} +#endif + #endif -- GitLab