Add BEAMMP_{WINDOWS,LINUX,APPLE} preprocessor defines instead of platform specific ones

This commit is contained in:
Lion Kortlepel
2021-11-27 02:11:22 +01:00
parent 9d2d4bb221
commit fd7bea0f36
7 changed files with 51 additions and 37 deletions

View File

@@ -115,11 +115,11 @@ std::string ThreadName(bool DebugModeOverride) {
void RegisterThread(const std::string& str) {
std::string ThreadId;
#ifdef WIN32
#ifdef BEAMMP_WINDOWS
ThreadId = std::to_string(GetCurrentThreadId());
#elif __APPLE__
#elif defined(BEAMMP_APPLE)
ThreadId = std::to_string(getpid()); // todo: research if 'getpid()' is a valid, posix compliant alternative to 'gettid()'
#else
#elif defined(BEAMMP_LINUX)
ThreadId = std::to_string(gettid());
#endif
if (Application::Settings.DebugModeEnabled) {
@@ -159,7 +159,7 @@ void LogChatMessage(const std::string& name, int id, const std::string& msg) {
}
std::string GetPlatformAgnosticErrorString() {
#ifdef WIN32
#ifdef BEAMMP_WINDOWS
// This will provide us with the error code and an error message, all in one.
int err;
char msgbuf[256];
@@ -180,7 +180,7 @@ std::string GetPlatformAgnosticErrorString() {
} else {
return std::to_string(GetLastError());
}
#else // posix
#elif defined(BEAMMP_LINUX) || defined(BEAMMP_APPLE)
return std::strerror(errno);
#endif
}