make error on MacOS
Closed this issue · 10 comments
cc -Icii/include -g -Wall -Wextra -D_FORTIFY_SOURCE=2 -I/usr/include/ncurses -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED -Inana/src -O3 -flto -DNDEBUG=1 -DWITHOUT_NANA=1 -std=c17 -DSHAREDIR=/usr/local/share/eisl -c main.c -o main.o
main.c:473:28: error: use of undeclared identifier '_SC_NPROCESSORS_CONF'
worker_count = sysconf(_SC_NPROCESSORS_CONF) - 1;
^
1 error generated.
make: *** [main.o] Error 1
It seems like _SC_NPROCESSORS_CONF
isn't exist in MacOS, please try sysctlbyname("hw.logicalcpu", ...)
. Also, please adding a line #include <pthread.h>
in eisl.h to get identifiers like pthread_cond_t
, it is important for clang.
I am sad to say even these errors are solved, eisl can not runs well on MacOS.
I appreciate the report. By the way, I do not own a Mac. It would be very helpful if someone could contribute to error fixing.
I added "#include <pthread.h>" to eisl.h. Will it work?
Yes it works, but it still can't be compiled unless i let worker_count = 2;
as mentioned above.
And I got a segmentation fault when running echo '(load "library/compiler.lsp") (compile-file "$<")' | ./eisl -r
.
In syntax.c queue
out of bound at line 2549, loading null pointer at line 2601.
I have understood the situation. I will carefully review the code.
I fixed. Will it work?
sysconf(_SC_NPROCESSORS_CONF) may operate correctly depending on the OS, and in such cases, it could potentially result in a negative number. It is assumed that the current CPU has at least 4 cores. Therefore, in the event of a negative number, we set it to 4 - 1 = 3.
No, it won't, because there is no macro _SC_NPROCESSORS_CONF
's definition unless the words -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED
in makefile are deleted. There is a condition in MacOS's :
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
#define _SC_NPROCESSORS_CONF 57
#define _SC_NPROCESSORS_ONLN 58
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
Although do so will make addwstr
no longer valid.
How about just define -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED
when including <ncurses.h> and <curses.h>, and undefine it after including like:
#define _XOPEN_SOURCE=700
#define _XOPEN_SOURCE_EXTENDED
#include <ncurse.h>
#undef _XOPEN_SOURCE
#undef _XOPEN_SOURCE_EXTENDED
I pulled a request. The changes allows the c files can be compiled on MacOS.
Thank you for the pull request. I have made modifications to make it work on Linux. Please accept them.
I closed this issue, for c codes compiling error had been solved.