[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] [PATCH] libgps.h: Fix linkage problem

From: Michal Privoznik
Subject: [gpsd-dev] [PATCH] libgps.h: Fix linkage problem
Date: Mon, 27 Oct 2014 03:10:17 +0100

When building with libQgpsmm=1 enabled I see this failure:

g++ -o libgps_core-qt.os -c -D_GNU_SOURCE -Wextra -Wall -Wno-uninitialized 
-Wno-missing-field-initializers -Wcast-align -Wmissing-declarations 
-Wmissing-prototypes -Wpointer-arith -Wreturn-type -pthread 
-Wmissing-declarations -O2 -pthread -fPIC -DUSE_QT -DQT_SHARED 
-I/usr/include/qt4 -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtCore 
cc1plus: warning: command line option '-Wmissing-prototypes' is valid for 
C/ObjC but not for C++
In file included from libgps_core.c:19:0:
gps_json.h:41:28: error: conflicting declaration of 'int json_ais_read(const 
char*, char*, size_t, ais_t*, const char**)' with 'C' linkage
     /address@hidden@*/const char **);
In file included from libgps_core.c:18:0:
libgps.h:34:12: note: previous declaration with 'C++' linkage
 extern int json_ais_read(const char *, char *, size_t, struct ais_t *,
scons: *** [libgps_core-qt.os] Error 1
scons: building terminated because of errors.

Digging more into the problem shows, libgps.h doesn't have the
functions enclosed within 'extern "C"' mark. Therefore, g++ mangled
the function names and hence the error.

Signed-off-by: Michal Privoznik <address@hidden>

I'm not sure if you allow long lines in commit messages, so feel
free to reword if needed.

Please note I'm not subscribed into the list so keep me CC'd.

 libgps.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libgps.h b/libgps.h
index f773188..914c4df 100644
--- a/libgps.h
+++ b/libgps.h
@@ -10,6 +10,9 @@
 #define SHM_PSEUDO_FD  -1
 #define DBUS_PSEUDO_FD -2
+#ifdef __cplusplus
+extern "C" {
 extern int gps_sock_open(/address@hidden@*/const char *, 
/address@hidden@*/const char *,
                      /address@hidden@*/struct gps_data_t *);
 extern int gps_sock_close(struct gps_data_t *);
@@ -33,6 +36,9 @@ extern int gps_dbus_mainloop(struct gps_data_t *, int,
 extern int json_ais_read(const char *, char *, size_t, struct ais_t *,
                  /address@hidden@*/const char **);
+#ifdef __cplusplus
 #define PRIVATE(gpsdata) ((struct privdata_t *)(gpsdata)->privdata)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]