Fix #1305 - add #ifdef __cplusplus for C++ linkage

This commit is contained in:
cpq 2021-07-13 06:58:34 +01:00
parent f46453f80f
commit 015586950f
3 changed files with 14 additions and 2 deletions

View File

@ -47,7 +47,7 @@ mg_prefix: mongoose.c mongoose.h
# C++ build
test++: CLANG = g++
test++: WARN += -Wno-shadow -Wno-missing-field-initializers -Wno-deprecated
test++: unamalgamated
test++: test
# Make sure we can build from an unamalgamated sources
unamalgamated: $(SRCS) $(HDRS) Makefile
@ -108,7 +108,7 @@ mongoose.c: $(SRCS) Makefile
(cat src/license.h; echo; echo '#include "mongoose.h"' ; (for F in src/private.h src/*.c ; do echo; echo '#ifdef MG_ENABLE_LINES'; echo "#line 1 \"$$F\""; echo '#endif'; cat $$F | sed -e 's,#include ".*,,'; done))> $@
mongoose.h: $(HDRS) Makefile
(cat src/license.h src/version.h ; cat src/arch.h src/arch_*.h src/config.h src/str.h src/log.h src/timer.h src/util.h src/url.h src/iobuf.h src/base64.h src/md5.h src/sha1.h src/event.h src/net.h src/http.h src/ssi.h src/tls.h src/ws.h src/sntp.h src/mqtt.h src/dns.h | sed -e 's,#include ".*,,' -e 's,^#pragma once,,')> $@
(cat src/license.h src/version.h ; cat src/arch.h src/arch_*.h src/config.h src/str.h src/log.h src/timer.h src/util.h src/url.h src/iobuf.h src/base64.h src/md5.h src/sha1.h src/event.h src/net.h src/http.h src/ssi.h src/tls.h src/ws.h src/sntp.h src/mqtt.h src/dns.h | sed -e 's,#include ".*,,' -e 's,^#pragma once,,'; echo; echo '#ifdef __cplusplus'; echo '}'; echo '#endif')> $@
clean: EXAMPLE_TARGET = clean
clean: ex

View File

@ -17,6 +17,10 @@
#pragma once
#define MG_VERSION "7.3"
#ifdef __cplusplus
extern "C" {
#endif
#define MG_ARCH_CUSTOM 0
#define MG_ARCH_UNIX 1
@ -959,3 +963,7 @@ bool mg_dns_parse(const uint8_t *buf, size_t len, struct mg_dns_message *);
size_t mg_dns_parse_rr(const uint8_t *buf, size_t len, size_t ofs,
bool is_question, struct mg_dns_rr *);
size_t mg_dns_decode_name(const uint8_t *, size_t, size_t, char *, size_t);
#ifdef __cplusplus
}
#endif

View File

@ -1,2 +1,6 @@
#pragma once
#define MG_VERSION "7.3"
#ifdef __cplusplus
extern "C" {
#endif