fix(build): fix macOS compilation errors

This commit is contained in:
vdm-dev 2024-02-18 15:31:21 +04:00
parent b3ae2d1ebd
commit efe062ca6b
2 changed files with 31 additions and 4 deletions

View file

@ -5,12 +5,19 @@
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#if defined(WHOA_SYSTEM_LINUX)
# include <sys/stat.h>
# include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#endif
#if defined(WHOA_SYSTEM_MAC)
# include <mach/mach_time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <mach/mach_time.h>
#include <mach-o/dyld.h>
#include <sys/syslimits.h>
#endif
@ -163,7 +170,25 @@ static const char* PrependDefaultDir(char* newfilename, uint32_t newfilenamesize
#endif
#if defined(WHOA_SYSTEM_MAC)
// TODO: GetModuleFileName() for Mac implementation
newfilename[0] = '\0';
char path[PATH_MAX] = {0};
char actualPath[PATH_MAX] = {0};
uint32_t size = PATH_MAX;
if (_NSGetExecutablePath(path, &size) == 0) {
if (!realpath(path, actualPath)) {
actualPath[0] = '\0';
}
}
char* slash = SStrChrR(actualPath, '/');
if (slash) {
slash[0] = '\0';
}
SStrCopy(newfilename, actualPath, newfilenamesize);
SStrPack(newfilename, "/", newfilenamesize);
SStrPack(newfilename, filename, newfilenamesize);
#endif
}

View file

@ -2,6 +2,8 @@
#define STORM_LOG_HPP
#include <cstdarg>
#include "storm/Common.hpp"
#include "storm/String.hpp"