Skip to content

Commit 437dd65

Browse files
fix: stdio in macOS
If the macro `NDEBUG` is defined, then the statements in `assert` will not be executed ( https://github.com/Project-LemonLime/Project_LemonLime/blob/6bdde219949b8f75f34f44adec3ba9878535e2fb/unix/watcher_macos.cpp#L93 ).[1] This problem has been introduced since 18ea8d8 , because CMake will define macro `NDEBUG` in release build (We compiled it by ourselves before and did not define this macro) [1]: https://en.cppreference.com/w/cpp/error/assert
1 parent e8364ff commit 437dd65

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

makespec/BUILDVERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
153
1+
155

unix/watcher_macos.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
#include <cstring>
1414
#include <errno.h>
1515
#include <sys/resource.h>
16+
#include <sys/sysctl.h>
1617
#include <sys/time.h>
1718
#include <sys/types.h>
1819
#include <sys/wait.h>
19-
#include <sys/sysctl.h>
2020
#include <unistd.h>
2121

2222
int pid;
@@ -30,8 +30,7 @@ void cleanUp(int dummy)
3030
int processIsTranslated() {
3131
int ret = 0;
3232
size_t size = sizeof(ret);
33-
if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1)
34-
{
33+
if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1) {
3534
if (errno == ENOENT)
3635
return 0;
3736
return -1;
@@ -96,13 +95,13 @@ int main(int argc, char *argv[]) {
9695
else
9796
{
9897
if (strlen(argv[2]) > 0)
99-
assert(freopen(argv[2], "r", stdin));
98+
freopen(argv[2], "r", stdin);
10099

101100
if (strlen(argv[3]) > 0)
102-
assert(freopen(argv[3], "w", stdout));
101+
freopen(argv[3], "w", stdout);
103102

104103
if (strlen(argv[4]) > 0)
105-
assert(freopen(argv[4], "w", stderr));
104+
freopen(argv[4], "w", stderr);
106105

107106
rlimit memlim, stalim, timlim;
108107

0 commit comments

Comments
 (0)