From 88cc1c05fd7ee271da54a412e2e62d8f5316ea10 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Tue, 4 Jul 2017 06:18:14 +0000 Subject: [PATCH] Fully fixed C library code to be compilable in C++ mode (polyglot). --- c/qrcodegen.c | 12 +++++++++--- c/qrcodegen.h | 8 -------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/c/qrcodegen.c b/c/qrcodegen.c index 8d4a233..e86a1de 100644 --- a/c/qrcodegen.c +++ b/c/qrcodegen.c @@ -27,10 +27,16 @@ #include #include "qrcodegen.h" -#ifdef QRCODEGEN_TEST - #define testable // Expose private functions -#else +#ifndef QRCODEGEN_TEST #define testable static // Keep functions private +#else + // Expose private functions + #ifndef __cplusplus + #define testable + #else + // Needed for const variables because they are treated as implicitly 'static' in C++ + #define testable extern + #endif #endif diff --git a/c/qrcodegen.h b/c/qrcodegen.h index ebb80d4..389c523 100644 --- a/c/qrcodegen.h +++ b/c/qrcodegen.h @@ -77,10 +77,6 @@ enum qrcodegen_Mask { /*---- Functions to generate QR Codes ----*/ -#ifdef __cplusplus -extern "C" { -#endif - /* * Encodes the given text string to a QR Code symbol, returning true if encoding succeeded. * If the data is too long to fit in any version in the given range @@ -144,7 +140,3 @@ int qrcodegen_getSize(const uint8_t qrcode[]); * If the given coordinates are out of bounds, then false (white) is returned. */ bool qrcodegen_getModule(const uint8_t qrcode[], int x, int y); - -#ifdef __cplusplus -} -#endif