From 6597c9b777b608a96974b4a7a8c15234b05ffdd8 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 26 Jul 2016 22:36:33 +0300 Subject: Cleanup DLL export/import --- butl/buildfile | 4 ++-- butl/export | 8 ++++++-- butl/filesystem | 4 ++-- butl/filesystem.ixx | 24 ++++++++++++++++++------ butl/process | 2 +- butl/string-table | 2 +- butl/utility | 4 ++-- 7 files changed, 32 insertions(+), 16 deletions(-) (limited to 'butl') diff --git a/butl/buildfile b/butl/buildfile index 7a3c442..d2d16ac 100644 --- a/butl/buildfile +++ b/butl/buildfile @@ -34,8 +34,8 @@ cxx.poptions =+ -I$src_root lib{butl}: cxx.export.poptions = -I$src_root -liba{hello}: cxx.export.poptions += -DLIBBUTL_STATIC -libs{hello}: cxx.export.poptions += -DLIBBUTL_SHARED +liba{butl}: cxx.export.poptions += -DLIBBUTL_STATIC +libs{butl}: cxx.export.poptions += -DLIBBUTL_SHARED obja{*}: cxx.poptions += -DLIBBUTL_STATIC_BUILD objs{*}: cxx.poptions += -DLIBBUTL_SHARED_BUILD diff --git a/butl/export b/butl/export index 2b5a5ac..bd7f188 100644 --- a/butl/export +++ b/butl/export @@ -6,8 +6,12 @@ #define BUTL_EXPORT // Normally we don't export class templates (but do complete specializations), -// inline functions, and classes without any member functions. But in the end -// it's all trial and error to figure out what VC needs exported. +// inline functions, and classes with only inline member functions. Exporting +// classes that inherit from non-exported/import bases (e.g., std::string) +// will end up badly. The only known workarounds are to not inherit or to not +// export. Also, MinGW GCC doesn't like seeing non-exported function being +// used before their inline definition. The workaround is to reorder code. In +// the end it's all trial and error. #if defined(LIBBUTL_STATIC) // Using static. # define LIBBUTL_EXPORT diff --git a/butl/filesystem b/butl/filesystem index 2c4f3a4..566f398 100644 --- a/butl/filesystem +++ b/butl/filesystem @@ -355,8 +355,8 @@ namespace butl // for (...: i) ... // ++i; // Invalid. // - inline dir_iterator begin (dir_iterator& i) {return std::move (i);} - inline dir_iterator end (const dir_iterator&) {return dir_iterator ();} + inline dir_iterator begin (dir_iterator&); + inline dir_iterator end (const dir_iterator&); } #include diff --git a/butl/filesystem.ixx b/butl/filesystem.ixx index 8e81b59..af1125e 100644 --- a/butl/filesystem.ixx +++ b/butl/filesystem.ixx @@ -85,6 +85,12 @@ namespace butl // dir_entry // inline entry_type dir_entry:: + ltype () const + { + return t_ != entry_type::unknown ? t_ : (t_ = type (false)); + } + + inline entry_type dir_entry:: type () const { entry_type t (ltype ()); @@ -93,12 +99,6 @@ namespace butl : lt_ != entry_type::unknown ? lt_ : (lt_ = type (true)); } - inline entry_type dir_entry:: - ltype () const - { - return t_ != entry_type::unknown ? t_ : (t_ = type (false)); - } - // dir_iterator // inline dir_iterator:: @@ -123,4 +123,16 @@ namespace butl { return !(x == y); } + + inline dir_iterator + begin (dir_iterator& i) + { + return std::move (i); + } + + inline dir_iterator + end (const dir_iterator&) + { + return dir_iterator (); + } } diff --git a/butl/process b/butl/process index fc8c1e8..ed9f798 100644 --- a/butl/process +++ b/butl/process @@ -17,7 +17,7 @@ namespace butl { - struct LIBBUTL_EXPORT process_error: std::system_error + struct process_error: std::system_error { bool child () const {return child_;} diff --git a/butl/string-table b/butl/string-table index cf2a20b..ae34419 100644 --- a/butl/string-table +++ b/butl/string-table @@ -38,7 +38,7 @@ namespace butl struct string_table_traits; template <> - struct LIBBUTL_EXPORT string_table_traits + struct string_table_traits { static const std::string& key (const std::string& d) {return d;} diff --git a/butl/utility b/butl/utility index 2436616..101d503 100644 --- a/butl/utility +++ b/butl/utility @@ -15,7 +15,7 @@ namespace butl { // Key comparators (i.e., to be used in sets, maps, etc). // - struct LIBBUTL_EXPORT compare_c_string + struct compare_c_string { bool operator() (const char* x, const char* y) const { @@ -23,7 +23,7 @@ namespace butl } }; - struct LIBBUTL_EXPORT compare_pointer_target + struct compare_pointer_target { template bool operator() (const P& x, const P& y) const {return *x < *y;} -- cgit v1.1