From 8299ba653b6a5bc85cf16de89df6d52055895512 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Tue, 3 Jan 2023 18:42:02 +0100 Subject: Fix exports --- Makefile | 6 +++++- common.mk | 1 + file.h | 10 ++++++---- mime.h | 4 +++- stringutil.h | 9 +++++---- tempfile.h | 4 +++- url.h | 4 +++- 7 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 1da3524..9604093 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,11 @@ SONAME1=libreichwein.so SONAME2=libreichwein.so.0 SONAME3=libreichwein.so.0.0.0 -CXXFLAGS+= -fvisibility=hidden -fPIC +# By default, don't export. Explicitly mark exports in C++ with: +# __attribute__((visibility("default"))) +CXXFLAGS+=-fvisibility=hidden + +CXXFLAGS+=-fPIC PROGSRC=\ file.cpp \ diff --git a/common.mk b/common.mk index 49a6266..9ec95e7 100644 --- a/common.mk +++ b/common.mk @@ -49,6 +49,7 @@ endif CXXFLAGS+=-Wall -I. CXXFLAGS+=-Wpedantic -gdwarf-4 +CXXFLAGS+=-fexceptions -Iexternal ifeq ($(CXX),clang++-11) CXXFLAGS+=-std=c++20 #-stdlib=libc++ diff --git a/file.h b/file.h index e7e4cf6..37653cb 100644 --- a/file.h +++ b/file.h @@ -5,11 +5,13 @@ #include #include +#define EXPORT __attribute__((visibility("default"))) + namespace File { -std::string getFile(const std::filesystem::path& filename); -void setFile(const std::filesystem::path& filename, const std::string& s); -void setFile(const std::filesystem::path& filename, const char* data, size_t size); -void setFile(const std::filesystem::path& filename, const std::vector& data); +EXPORT std::string getFile(const std::filesystem::path& filename); +EXPORT void setFile(const std::filesystem::path& filename, const std::string& s); +EXPORT void setFile(const std::filesystem::path& filename, const char* data, size_t size); +EXPORT void setFile(const std::filesystem::path& filename, const std::vector& data); } diff --git a/mime.h b/mime.h index c05eb45..8065d4f 100644 --- a/mime.h +++ b/mime.h @@ -2,4 +2,6 @@ #include -std::string mime_type(const std::string& path); +#define EXPORT __attribute__((visibility("default"))) + +EXPORT std::string mime_type(const std::string& path); diff --git a/stringutil.h b/stringutil.h index 5110e2e..6cd74aa 100644 --- a/stringutil.h +++ b/stringutil.h @@ -3,8 +3,9 @@ #include #include -std::string strfmt(const char* fmt, ...); +#define EXPORT __attribute__((visibility("default"))) -std::vector split(std::string value, const std::string separators = "\r\n "); -std::string join(std::vector vs, std::string separator = "\n"); -bool startsWithAnyOfLower(const std::string &s, const std::vector &list); +EXPORT std::string strfmt(const char* fmt, ...); +EXPORT std::vector split(std::string value, const std::string separators = "\r\n "); +EXPORT std::string join(std::vector vs, std::string separator = "\n"); +EXPORT bool startsWithAnyOfLower(const std::string &s, const std::vector &list); diff --git a/tempfile.h b/tempfile.h index b9839a7..46c7123 100644 --- a/tempfile.h +++ b/tempfile.h @@ -2,7 +2,9 @@ #include -class Tempfile +#define EXPORT __attribute__((visibility("default"))) + +EXPORT class Tempfile { std::filesystem::path m_path; diff --git a/url.h b/url.h index bd60616..c4745ab 100644 --- a/url.h +++ b/url.h @@ -2,5 +2,7 @@ #include -std::string urlDecode(std::string s); +#define EXPORT __attribute__((visibility("default"))) + +EXPORT std::string urlDecode(std::string s); -- cgit v1.2.3