From 2a37d1e74a5bc72f73f51474ee9d0e2514b6bb6e Mon Sep 17 00:00:00 2001 From: Blazczak Date: Mon, 24 Nov 2025 03:58:20 -0800 Subject: [PATCH] Similar to antirez/gguf-tools#19 and other Issues listed in antirez/gguf-tools, let's facilitate compilation in C++ with the addition of some basic ifdefs. Tested working. --- fp16.h | 6 ++++++ gguflib.h | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/fp16.h b/fp16.h index 10d2d82..1f29e8f 100644 --- a/fp16.h +++ b/fp16.h @@ -2,6 +2,12 @@ #ifndef FP16_h #define FP16_h +#ifdef __cplusplus +extern "C" { +#endif float from_half(uint16_t h); uint16_t to_half(float f); +#ifdef __cplusplus +} +#endif // __cplusplus #endif diff --git a/gguflib.h b/gguflib.h index 4cb973a..79e0d07 100644 --- a/gguflib.h +++ b/gguflib.h @@ -174,6 +174,10 @@ typedef struct { /* =============================== Prototypes =============================== */ +#ifdef __cplusplus +extern "C" { +#endif + gguf_ctx *gguf_open(const char *filename); gguf_ctx *gguf_create(const char *filename, int flags); int gguf_remap(gguf_ctx *ctx); @@ -198,4 +202,8 @@ float *gguf_tensor_to_float(gguf_tensor *tensor); int16_t *gguf_tensor_to_f16(gguf_tensor *tensor); int16_t *gguf_tensor_to_bf16(gguf_tensor *tensor); +#ifdef __cplusplus +} +#endif + #endif