]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Header fixes for compiling C++ source files
authorGeorge Joseph <gjoseph@sangoma.com>
Tue, 31 Dec 2024 18:10:20 +0000 (11:10 -0700)
committerGeorge Joseph <gjoseph@sangoma.com>
Thu, 2 Jan 2025 14:52:33 +0000 (14:52 +0000)
A few tweaks needed to be done to some existing header files to allow them to
be compiled when included from C++ source files.

logger.h had declarations for ast_register_verbose() and
ast_unregister_verbose() which caused C++ issues but those functions were
actually removed from logger.c many years ago so the declarations were just
removed from logger.h.

include/asterisk/astmm.h
include/asterisk/lock.h
include/asterisk/logger.h
include/asterisk/strings.h

index 1f4ec9560f2d50ee1b0c85d65fbf6af662100f69..5a68534b5bf09fc3b97c1c2554b8ab532411b2fa 100644 (file)
@@ -300,7 +300,7 @@ int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char
        ({                                                                \
                const char *__old = (s);                                  \
                size_t __len = strlen(__old) + 1;                         \
-               char *__new = __builtin_alloca(__len);                    \
+               char *__new = (char *)__builtin_alloca(__len);                    \
                memcpy (__new, __old, __len);                             \
                __new;                                                    \
        }))
index 18d15054338fa7868a6b72c3b565f669be40a11c..d959c1a11ef431e46d8e3e1767916c7bc13ccbaa 100644 (file)
 #include "asterisk/logger.h"
 #include "asterisk/compiler.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 #define AST_PTHREADT_NULL (pthread_t) -1
 #define AST_PTHREADT_STOP (pthread_t) -2
 
@@ -766,6 +770,10 @@ AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
        return ast_atomic_sub_fetch(p, 1, __ATOMIC_RELAXED) == 0;
 })
 
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
 /*! @} */
 
 #endif /* _ASTERISK_LOCK_H */
index d0d4fe6c665dbf29f6bec7cbacdf16824321153c..7f4c2adee989484ace18a569d8387eb979327fae 100644 (file)
@@ -190,9 +190,6 @@ void __attribute__((format(printf, 6, 0))) __ast_verbose_ap(const char *file, in
 
 void __attribute__((format(printf, 2, 3))) ast_child_verbose(int level, const char *fmt, ...);
 
-int ast_register_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result;
-int ast_unregister_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result;
-
 /*
  * These gymnastics are due to platforms which designate char as unsigned by
  * default.  Level is the negative character -- offset by 1, because \0 is
index 935c7e9236f25792c4349bc242c79a44994791e7..e9a541798b2395bb71a158f3f7f2db85bca160a3 100644 (file)
@@ -756,7 +756,7 @@ char * attribute_pure ast_str_buffer(const struct ast_str *buf),
        if (__builtin_expect(buf->__AST_STR_LEN > 0, 1)) {
                return (char *) buf->__AST_STR_STR;
        }
-       return "";
+       return (char *)"";
 }
 )