From 9998b5dddb066144c404bf5cee12c9521504f97d Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 28 Jan 2025 18:33:38 -0800 Subject: [PATCH] allow removal of extern "C" guards in C++ mode using new build macro XXH_NO_EXTERNC_GUARD --- README.md | 1 + xxhash.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4f9c21dd..1ff987b0 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ The following macros can be set at compilation time to modify `libxxhash`'s beha This build flag is useful for embedded environments without dynamic allocation. - `XXH_memcpy`, `XXH_memset`, `XXH_memcmp` : redirect `memcpy()`, `memset()` and `memcmp()` to some user-selected symbol at compile time. Redirecting all 3 removes the need to include `` standard library. +- `XXH_NO_EXTERNC_GUARD`: When `xxhash.h` is compiled in C++ mode, removes the `extern "C" { .. }` block guard. - `XXH_DEBUGLEVEL` : When set to any value >= 1, enables `assert()` statements. This (slightly) slows down execution, but may help finding bugs during debugging sessions. diff --git a/xxhash.h b/xxhash.h index 10826907..1ad2ddb6 100644 --- a/xxhash.h +++ b/xxhash.h @@ -241,7 +241,7 @@ * xxHash prototypes and implementation */ -#if defined (__cplusplus) +#if defined(__cplusplus) && !defined(XXH_NO_EXTERNC_GUARD) extern "C" { #endif @@ -7338,6 +7338,6 @@ XXH3_generateSecret_fromSeed(XXH_NOESCAPE void* secretBuffer, XXH64_hash_t seed) #endif /* XXH_IMPLEMENTATION */ -#if defined (__cplusplus) +#if defined (__cplusplus) && !defined(XXH_NO_EXTERNC_GUARD) } /* extern "C" */ #endif