[PATCH] Don't include headers under extern "C" unless we have to.

Thiago Macieira thiago at macieira.org
Sat Oct 5 12:11:46 UTC 2013


libxml headers include ICU headers and ICU has C++ code. If it detects
__cplusplus, it will start declaring C++ templates and whatnot, which
aren't allowed under extern "C".

Signed-off-by: Thiago Macieira <thiago at macieira.org>
---
 Rules.mk          | 8 ++++++--
 libdivecomputer.h | 8 ++++----
 uemis.h           | 8 ++++++++
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/Rules.mk b/Rules.mk
index ce1ba59..054223a 100644
--- a/Rules.mk
+++ b/Rules.mk
@@ -215,8 +215,12 @@ ui_%.h: %.ui .uic
 	@mkdir -p .uic/qt-ui
 	$(COMPILE_PREFIX)$(UIC) $< -o .uic/$@
 
-.uic:
-	$(COMPILE_PREFIX)mkdir $@
+# This forces the creation of ui headers with the wrong path
+# This is required because the -MG option to the compiler outputs
+# unknown files with no path prefix
+ui_%.h: qt-ui/%.ui
+	@$(PRETTYECHO) '    UIC' $<
+	$(COMPILE_PREFIX)$(UIC) $< -o qt-ui/$@
 
 share/locale/%.UTF-8/LC_MESSAGES/$(NAME).mo: po/%.po po/%.aliases
 	@$(PRETTYECHO) '    MSGFMT' $*.po
diff --git a/libdivecomputer.h b/libdivecomputer.h
index 4bb0239..07d965e 100644
--- a/libdivecomputer.h
+++ b/libdivecomputer.h
@@ -2,10 +2,6 @@
 #define LIBDIVECOMPUTER_H
 
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /* libdivecomputer */
 #include <libdivecomputer/version.h>
 #include <libdivecomputer/device.h>
@@ -14,6 +10,10 @@ extern "C" {
 /* handling uemis Zurich SDA files */
 #include "uemis.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* don't forget to include the UI toolkit specific display-XXX.h first
    to get the definition of progressbar_t */
 typedef struct device_data_t {
diff --git a/uemis.h b/uemis.h
index f8489f5..66a2b91 100644
--- a/uemis.h
+++ b/uemis.h
@@ -8,6 +8,10 @@
 #include <stdint.h>
 #include "dive.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void uemis_parse_divelog_binary(char *base64, void *divep);
 int uemis_get_weight_unit(int diveid);
 void uemis_mark_divelocation(int diveid, int divespot, char **location, degrees_t *longitude, degrees_t *latitude);
@@ -41,4 +45,8 @@ typedef struct {
 	uint8_t		flags[8];
 } __attribute((packed)) uemis_sample_t;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* UEMIS_H */
-- 
1.7.11.7



More information about the subsurface mailing list