Skip to content

Commit

Permalink
make symbol visibility=hidden by default
Browse files Browse the repository at this point in the history
  • Loading branch information
bebuch committed Jul 18, 2018
1 parent 6bd77d6 commit 7ba4491
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Jamroot.jam
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ project logsys

<toolset>gcc:<cxxflags>-std=c++1z
<toolset>gcc:<cxxflags>-fconstexpr-depth=1024
<toolset>gcc:<cxxflags>-fvisibility=hidden
<toolset>gcc:<cxxflags>-Wall
<toolset>gcc:<cxxflags>-Wextra
<toolset>gcc:<linkflags>-lpthread

<toolset>clang:<cxxflags>-std=c++1z
<toolset>clang:<cxxflags>-fconstexpr-depth=1024
<toolset>clang:<cxxflags>-fvisibility=hidden
<toolset>clang:<cxxflags>-Wall
<toolset>clang:<cxxflags>-Wextra
<toolset>clang:<cxxflags>-stdlib=libc++
Expand Down
10 changes: 5 additions & 5 deletions include/logsys/stdlogb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#ifndef _logsys__stdlogb__hpp_INCLUDED_
#define _logsys__stdlogb__hpp_INCLUDED_

#include <boost/config.hpp>

#include <iostream>
#include <memory>

Expand All @@ -17,14 +19,12 @@ namespace logsys{


/// \brief Base class for dynamic log tag classes
class stdlogb{
class BOOST_SYMBOL_EXPORT stdlogb{
public:
/// \brief Create a stdlogb derived log object
///
/// There are two ways to use this function:
/// 1. You can just include the header and write your own definition.
/// 2. You can link agains logsys/liblogsys.so and assign your log
/// object creater function to stdlogb_factory_object.
/// Link against logsys/liblogsys.so and assign your log object creater
/// function to stdlogb_factory_object.
static std::unique_ptr< stdlogb > factory()noexcept;

/// \brief Destructor
Expand Down
5 changes: 4 additions & 1 deletion include/logsys/stdlogb_factory_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#ifndef _logsys__stdlogb_factory_object__hpp_INCLUDED_
#define _logsys__stdlogb_factory_object__hpp_INCLUDED_

#include <boost/config.hpp>

#include <memory>
#include <functional>

Expand All @@ -19,7 +21,8 @@ namespace logsys{
class stdlogb;

/// \brief Assign your log object maker to this variable
extern std::function< std::unique_ptr< stdlogb >() > stdlogb_factory_object;
extern BOOST_SYMBOL_EXPORT
std::unique_ptr< stdlogb >(*stdlogb_factory_object)()noexcept;


}
Expand Down
3 changes: 3 additions & 0 deletions src/stdlogb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
#include <logsys/stdlogb_factory_object.hpp>
#include <logsys/stdlogb.hpp>

#include <cassert>


namespace logsys{


std::unique_ptr< stdlogb > stdlogb::factory()noexcept try{
assert(stdlogb_factory_object != nullptr);
return stdlogb_factory_object();
}catch(std::exception const& e){
std::cerr << "terminate with exception in stdlogb factory: "
Expand Down
7 changes: 4 additions & 3 deletions src/stdlogb_factory_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
namespace logsys{


std::function< std::unique_ptr< stdlogb >() > stdlogb_factory_object(
[](){ return std::make_unique< stdlogd >(); }
);
std::unique_ptr< stdlogb >(*stdlogb_factory_object)()noexcept =
[]()noexcept->std::unique_ptr< stdlogb >{
return std::make_unique< stdlogd >();
};


}

0 comments on commit 7ba4491

Please sign in to comment.