Closed chitramdasgupta closed 2 years ago
Try adding the line #include <sys/types.h>
in common/util.h
.
No luck compiling it.
I added #include <sys/types.h>
to the file common/util.h
But this still results in compilation errors:
mkdir -p bin
clang -o emu/libemu.o -c emu/libemu.c -std=c11 -O0 -g -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wno-pointer-arith -Wno-unused-parameter -Wno-gnu-zero-variadic-macro-arguments
emu/libemu.c:45:17: warning: implicit declaration of function 'clock_gettime' is invalid in C99 [-Wimplicit-function-declaration]
u64 start = NOW(),
^
emu/libemu.c:15:17: note: expanded from macro 'NOW'
assert(!clock_gettime(MONO_CLOCK, &ts)); \
^
emu/libemu.c:45:17: error: use of undeclared identifier '_CLOCK_MONOTONIC_RAW'
emu/libemu.c:15:31: note: expanded from macro 'NOW'
assert(!clock_gettime(MONO_CLOCK, &ts)); \
^
emu/libemu.c:10:21: note: expanded from macro 'MONO_CLOCK'
#define MONO_CLOCK _CLOCK_MONOTONIC_RAW
^
emu/libemu.c:51:15: warning: implicit declaration of function 'clock_gettime' is invalid in C99 [-Wimplicit-function-declaration]
now = NOW();
^
emu/libemu.c:15:17: note: expanded from macro 'NOW'
assert(!clock_gettime(MONO_CLOCK, &ts)); \
^
emu/libemu.c:51:15: error: use of undeclared identifier '_CLOCK_MONOTONIC_RAW'
emu/libemu.c:15:31: note: expanded from macro 'NOW'
assert(!clock_gettime(MONO_CLOCK, &ts)); \
^
emu/libemu.c:10:21: note: expanded from macro 'MONO_CLOCK'
#define MONO_CLOCK _CLOCK_MONOTONIC_RAW
^
emu/libemu.c:82:41: warning: implicit declaration of function 'clock_gettime' is invalid in C99 [-Wimplicit-function-declaration]
u64 sleep_time = ns_per_step - (NOW() - now);
^
emu/libemu.c:15:17: note: expanded from macro 'NOW'
assert(!clock_gettime(MONO_CLOCK, &ts)); \
^
emu/libemu.c:82:41: error: use of undeclared identifier '_CLOCK_MONOTONIC_RAW'
emu/libemu.c:15:31: note: expanded from macro 'NOW'
assert(!clock_gettime(MONO_CLOCK, &ts)); \
^
emu/libemu.c:10:21: note: expanded from macro 'MONO_CLOCK'
#define MONO_CLOCK _CLOCK_MONOTONIC_RAW
^
emu/libemu.c:86:9: warning: implicit declaration of function 'nanosleep' is invalid in C99 [-Wimplicit-function-declaration]
SLEEP(sleep_time);
^
emu/libemu.c:25:13: note: expanded from macro 'SLEEP'
nanosleep(&req, &rem); \
^
4 warnings and 3 errors generated.
make: *** [Makefile:57: emu/libemu.o] Error 1
Try adding #define _POSIX_C_SOURCE 199309L
at the beginning of emu/libemu.c
right before #include <time.h>
I added #define _POSIX_C_SOURCE 199309L
at the beginning of emu/libemu.c
and I got the following error:
clang -o emu/libemu.o -c emu/libemu.c -std=c11 -O0 -g -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wno-pointer-arith -Wno-unused-parameter -Wno-gnu-zero-variadic-macro-arguments
emu/libemu.c:46:17: error: use of undeclared identifier '_CLOCK_MONOTONIC_RAW'
u64 start = NOW(),
^
emu/libemu.c:16:31: note: expanded from macro 'NOW'
assert(!clock_gettime(MONO_CLOCK, &ts)); \
^
emu/libemu.c:11:21: note: expanded from macro 'MONO_CLOCK'
#define MONO_CLOCK _CLOCK_MONOTONIC_RAW
^
emu/libemu.c:52:15: error: use of undeclared identifier '_CLOCK_MONOTONIC_RAW'
now = NOW();
^
emu/libemu.c:16:31: note: expanded from macro 'NOW'
assert(!clock_gettime(MONO_CLOCK, &ts)); \
^
emu/libemu.c:11:21: note: expanded from macro 'MONO_CLOCK'
#define MONO_CLOCK _CLOCK_MONOTONIC_RAW
^
emu/libemu.c:83:41: error: use of undeclared identifier '_CLOCK_MONOTONIC_RAW'
u64 sleep_time = ns_per_step - (NOW() - now);
^
emu/libemu.c:16:31: note: expanded from macro 'NOW'
assert(!clock_gettime(MONO_CLOCK, &ts)); \
^
emu/libemu.c:11:21: note: expanded from macro 'MONO_CLOCK'
#define MONO_CLOCK _CLOCK_MONOTONIC_RAW
^
3 errors generated.
make: *** [Makefile:57: emu/libemu.o] Error 1
_CLOCK_MONOTIC_RAW
seems to be the culprit.
Instead of doing it in 'libemu.c' do it in 'emu.c' right before the line that says '#include
But there is no '#include emu.c
My bad, it was only in libemu.c
. Replace _CLOCK_MONOTONIC_RAW
with CLOCK_MONOTONIC_RAW
in libemu.c
.
On Archlinux, I found out I have to change two more things to build it.
Makefile
, capitalise all occurrence of sdl
.emu/emu.c
, use strncpy
instead of strlcpy
as it's a BSD thing.This is all in with ca57c54798f0a9c00a0f882c52dfd548c6fb9fdb, can anyone running arch confirm that these changes work?
Again, -lSDL2
is needed instead of -lsdl2
, and strlcpy
isn't a POSIX function. :)
Ah, yeah, can see it's a nonstandard BSD thing.
But on the capitalisation of SDL
, is there any easy way to detect Arch specifically (or preferably just the presence of SDL2
over sdl2
)? I have no machine to test on.
Okay, Arch should now be fixed. But it depends on ARCH_LINUX := $(shell grep "Arch Linux" /etc/os-release 2>/dev/null)
working on Arch, so can anyone confirm now that it works properly?
Why not use sdl-config
just like on Windows?
@MikeWalrus I dont think it would work because I dont think sdl-config works on arch linux (and jdah im gonna get an arch vm soon to test it out)
@MikeWalrus I dont think it would work because I dont think sdl-config works on arch linux (and jdah im gonna get an arch vm soon to test it out)
I think sdl2-config --cflags --libs
do work though.
@MikeWalrus I dont think it would work because I dont think sdl-config works on arch linux (and jdah im gonna get an arch vm soon to test it out)
I think
sdl2-config --cflags --libs
do work though.
Probably... you can try
@chitramdasgupta It works on arch linux...
This is all in with ca57c54, can anyone running arch confirm that these changes work?
@jdah Yup! It works
Requesting close to this issue as problem has been fixed
So I did the following:
And I get the following error: