Skip to content

Commit

Permalink
Added ifdefs for correct use of localtime_r/s
Browse files Browse the repository at this point in the history
  • Loading branch information
calmcl1 committed Feb 27, 2017
1 parent b7cc4d2 commit dcb2870
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions chronicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,11 @@ void doRecord(boost::filesystem::path directory, string fileNameFormat) {
char audioFileName[81];
time_t now_tt = chrono::system_clock::to_time_t(chrono::system_clock::now());
struct tm now_tm;
localtime_s(&now_tm, &now_tt);

#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__))
localtime_s(&now_tm, &now_tt); // Use localtime_s on windows
#else
localtime_r(&now_tt, &now_tm); // Use localtime_r on POSIX
#endif
strftime(audioFileName, 80, fileNameFormat.c_str(), &now_tm);

boost::filesystem::path audioFileFullPath;
Expand Down

0 comments on commit dcb2870

Please sign in to comment.