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

a patch add missing extern "C"



While using libdpkg-dev, I have some symbol finding issue when I try to link to `libdpkg.a`. It turns out that some header files I used do not have `extern "C"`.

This is my first time trying to contribute to debian. Sorry for any mistake I may have made.
From 52fa9b2f73e589fab8439809c2bab0e82942e8af Mon Sep 17 00:00:00 2001
From: black_desk <clx814727823@gmail.com>
Date: Tue, 16 Nov 2021 17:21:22 +0800
Subject: [PATCH] libdpkg: Add missing extern "C"

---
 lib/dpkg/db-ctrl.h   | 4 ++++
 lib/dpkg/db-fsys.h   | 4 ++++
 lib/dpkg/fsys.h      | 4 ++++
 lib/dpkg/parsedump.h | 4 ++++
 lib/dpkg/perf.h      | 6 ++++++
 lib/dpkg/tarfn.h     | 4 ++++
 6 files changed, 26 insertions(+)

diff --git a/lib/dpkg/db-ctrl.h b/lib/dpkg/db-ctrl.h
index e4dccd285..d21bb7c66 100644
--- a/lib/dpkg/db-ctrl.h
+++ b/lib/dpkg/db-ctrl.h
@@ -25,6 +25,8 @@
 
 #include <dpkg/dpkg-db.h>
 
+DPKG_BEGIN_DECLS
+
 enum pkg_infodb_format {
 	PKG_INFODB_FORMAT_UNKNOWN = -1,
 	PKG_INFODB_FORMAT_LEGACY = 0,
@@ -49,4 +51,6 @@ typedef void pkg_infodb_file_func(const char *filename, const char *filetype);
 void pkg_infodb_foreach(struct pkginfo *pkg, struct pkgbin *pkgbin,
                         pkg_infodb_file_func *func);
 
+DPKG_END_DECLS
+
 #endif /* LIBDPKG_DB_CTRL_H */
diff --git a/lib/dpkg/db-fsys.h b/lib/dpkg/db-fsys.h
index 339a0fb45..cd9abefaf 100644
--- a/lib/dpkg/db-fsys.h
+++ b/lib/dpkg/db-fsys.h
@@ -25,6 +25,8 @@
 #include <dpkg/file.h>
 #include <dpkg/fsys.h>
 
+DPKG_BEGIN_DECLS
+
 /*
  * Data structure here is as follows:
  *
@@ -72,4 +74,6 @@ void write_filelist_except(struct pkginfo *pkg, struct pkgbin *pkgbin,
 void write_filehash_except(struct pkginfo *pkg, struct pkgbin *pkgbin,
                            struct fsys_namenode_list *list, enum fsys_namenode_flags mask);
 
+DPKG_END_DECLS
+
 #endif /* LIBDPKG_DB_FSYS_H */
diff --git a/lib/dpkg/fsys.h b/lib/dpkg/fsys.h
index 748f3a9af..8c78c77ac 100644
--- a/lib/dpkg/fsys.h
+++ b/lib/dpkg/fsys.h
@@ -26,6 +26,8 @@
 
 #include <dpkg/file.h>
 
+DPKG_BEGIN_DECLS
+
 /*
  * Data structure here is as follows:
  *
@@ -203,4 +205,6 @@ const char *dpkg_fsys_set_dir(const char *dir);
 const char *dpkg_fsys_get_dir(void);
 char *dpkg_fsys_get_path(const char *pathpart);
 
+DPKG_END_DECLS
+
 #endif /* LIBDPKG_FSYS_H */
diff --git a/lib/dpkg/parsedump.h b/lib/dpkg/parsedump.h
index 73331bca5..316cd1b51 100644
--- a/lib/dpkg/parsedump.h
+++ b/lib/dpkg/parsedump.h
@@ -27,6 +27,8 @@
 
 #include <dpkg/error.h>
 
+DPKG_BEGIN_DECLS
+
 /**
  * @defgroup parsedump In-core package database parsing and reading
  * @ingroup dpkg-public
@@ -163,4 +165,6 @@ extern const struct fieldinfo fieldinfos[];
 
 /** @} */
 
+DPKG_END_DECLS
+
 #endif /* LIBDPKG_PARSEDUMP_H */
diff --git a/lib/dpkg/perf.h b/lib/dpkg/perf.h
index 6b5d0befd..b978c6c38 100644
--- a/lib/dpkg/perf.h
+++ b/lib/dpkg/perf.h
@@ -30,6 +30,10 @@
 #define TEST_OMIT_VARIABLES
 #include <dpkg/test.h>
 
+#include <dpkg/macros.h>
+
+DPKG_BEGIN_DECLS
+
 struct perf_slot {
 	struct timespec t_ini, t_end;
 };
@@ -70,4 +74,6 @@ perf_ts_slot_print(struct perf_slot *ps, const char *str)
 #define perf_ts_slot_start(ps) clock_gettime(CLOCK_MONOTONIC, &((ps)->t_ini))
 #define perf_ts_slot_stop(ps) clock_gettime(CLOCK_MONOTONIC, &((ps)->t_end))
 
+DPKG_END_DECLS
+
 #endif
diff --git a/lib/dpkg/tarfn.h b/lib/dpkg/tarfn.h
index 4d5917cfc..c03a59310 100644
--- a/lib/dpkg/tarfn.h
+++ b/lib/dpkg/tarfn.h
@@ -29,6 +29,8 @@
 #include <dpkg/error.h>
 #include <dpkg/file.h>
 
+DPKG_BEGIN_DECLS
+
 /**
  * @defgroup tar Tar archive handling
  * @ingroup dpkg-public
@@ -127,4 +129,6 @@ tar_extractor(struct tar_archive *tar);
 
 /** @} */
 
+DPKG_END_DECLS
+
 #endif
-- 
2.33.0


Reply to: