Skip to content

Commit 311bebc

Browse files
committed
plat: compile specific code according to your os
1 parent b28e9bd commit 311bebc

File tree

5 files changed

+5
-28
lines changed

5 files changed

+5
-28
lines changed

CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,10 @@ aux_source_directory(./src/time SRC_TIME)
2626
aux_source_directory(./src/tool SRC_TOOL)
2727

2828
# platform codes
29-
if (APPLE)
30-
# rarely used, if you want to do some things on OS X only
31-
add_definitions(-DCHEN_OS_APPLE)
32-
endif()
33-
3429
if (UNIX)
35-
add_definitions(-DCHEN_OS_UNIX)
3630
aux_source_directory(./src/plat/unix SRC_PLAT)
3731
elseif(WIN32)
38-
add_definitions(-DCHEN_OS_WIN)
39-
aux_source_directory(./src/plat/win32 SRC_PLAT)
32+
aux_source_directory(./src/plat/win SRC_PLAT)
4033
else()
4134
message(FATAL_ERROR "Unsupported system")
4235
endif()

src/plat/unix/date_unix.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* @author Jian Chen <admin@chensoft.com>
55
* @link http://chensoft.com
66
*/
7-
#ifdef CHEN_OS_UNIX
8-
97
#include <chen/time/date.hpp>
108

119
using namespace chen;
@@ -24,6 +22,4 @@ struct tm date::localtime(std::time_t time)
2422
struct tm now = {0};
2523
::localtime_r(&time, &now);
2624
return now;
27-
}
28-
29-
#endif
25+
}

src/plat/unix/fs_unix.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* @author Jian Chen <admin@chensoft.com>
55
* @link http://chensoft.com
66
*/
7-
#ifdef CHEN_OS_UNIX
8-
97
#include <chen/sys/fs.hpp>
108
#include <chen/base/str.hpp>
119
#include <fstream>
@@ -295,6 +293,4 @@ void fs::visit(const std::string &directory,
295293
}
296294

297295
::closedir(dir);
298-
}
299-
300-
#endif
296+
}

src/plat/unix/sys_unix.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* @author Jian Chen <admin@chensoft.com>
55
* @link http://chensoft.com
66
*/
7-
#ifdef CHEN_OS_UNIX
8-
97
#include <chen/sys/sys.hpp>
108
#include <sys/stat.h>
119
#include <execinfo.h>
@@ -67,6 +65,4 @@ std::vector<std::string> sys::stack()
6765
::free(list);
6866

6967
return ret;
70-
}
71-
72-
#endif // CHEN_OS_UNIX
68+
}

src/plat/win32/date_win.cpp renamed to src/plat/win/date_win.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* @author Jian Chen <admin@chensoft.com>
55
* @link http://chensoft.com
66
*/
7-
#ifdef CHEN_OS_UNIX
8-
97
#include <chen/base/date.hpp>
108

119
using namespace chen;
@@ -24,6 +22,4 @@ struct tm date::localtime(std::time_t time)
2422
struct tm now = {0};
2523
::localtime_s(&now, &time);
2624
return now;
27-
}
28-
29-
#endif
25+
}

0 commit comments

Comments
 (0)