77 * This library is released under MIT license
88 */
99
10- #if !defined( _WIN32)
10+ #ifndef _WIN32
1111#include < dlfcn.h>
1212#include < unistd.h>
1313#endif
@@ -44,31 +44,31 @@ std::vector<internal_symbol_info> get_symbols(native_handle_type handle, int fd)
4444std::string demangle_symbol (const char *symbol);
4545
4646static native_handle_type open_lib (const char *path) noexcept {
47- #if defined( _WIN32)
47+ #ifdef _WIN32
4848 return LoadLibraryA (path);
4949#else
5050 return dlopen (path, RTLD_NOW | RTLD_LOCAL );
5151#endif
5252}
5353
5454static native_symbol_type locate_symbol (native_handle_type lib, const char *name) noexcept {
55- #if defined( _WIN32)
55+ #ifdef _WIN32
5656 return GetProcAddress (lib, name);
5757#else
5858 return dlsym (lib, name);
5959#endif
6060}
6161
6262static void close_lib (native_handle_type lib) noexcept {
63- #if defined( _WIN32)
63+ #ifdef _WIN32
6464 FreeLibrary (lib);
6565#else
6666 dlclose (lib);
6767#endif
6868}
6969
7070static std::string get_error_description () noexcept {
71- #if defined( _WIN32)
71+ #ifdef _WIN32
7272 WORD lang = MAKELANGID (LANG_ENGLISH , SUBLANG_ENGLISH_US );
7373 char description[512 ];
7474 DWORD error_code;
@@ -91,15 +91,15 @@ static std::string get_error_description() noexcept {
9191
9292library::library (library &&other) noexcept {
9393 std::swap (m_handle, other.m_handle );
94- #if defined( __APPLE__)
94+ #ifdef __APPLE__
9595 std::swap (m_fd, other.m_fd );
9696#endif
9797}
9898
9999library &library::operator =(library &&other) noexcept {
100100 if (this != &other) {
101101 std::swap (m_handle, other.m_handle );
102- #if defined( __APPLE__)
102+ #ifdef __APPLE__
103103 std::swap (m_fd, other.m_fd );
104104#endif
105105 }
@@ -116,7 +116,7 @@ library::library(const char *lib_path, dylib::decorations decorations) {
116116
117117 lib = lib_path;
118118
119- #if defined( _WIN32)
119+ #ifdef _WIN32
120120 while (lib.find (' \\ ' ) != std::string::npos)
121121 lib.replace (lib.find (' \\ ' ), 1 , " /" );
122122#endif
@@ -139,7 +139,7 @@ library::library(const char *lib_path, dylib::decorations decorations) {
139139 if (!m_handle)
140140 throw load_error (" Could not load library '" + lib + " ':\n " + get_error_description ());
141141
142- #if defined( __APPLE__)
142+ #ifdef __APPLE__
143143 m_fd = open (lib.c_str (), O_RDONLY );
144144 if (m_fd < 0 )
145145 throw load_error (" Could not open file '" + lib + " ':\n " + strerror (errno));
@@ -157,7 +157,7 @@ library::library(const std::filesystem::path &lib_path, decorations decorations)
157157library::~library () {
158158 if (m_handle)
159159 close_lib (m_handle);
160- #if defined( __APPLE__)
160+ #ifdef __APPLE__
161161 if (m_fd > -1 )
162162 close (m_fd);
163163#endif
0 commit comments