Stefanos via Tinycc-devel <[email protected]> wrote: > I have tried with the latest commit 7e4fc3a0d01173575b3b29f71ae4da87322ba14b > the following configuration setting > > ./configure --extra-cflags='-std=c99' > > > just for the sake of experimentation and have found there's a problematic > behavior which probably is my fault, but have no idea what am I doing wrong > here... > > My command is: > > make clean && make -j4 && make test
which compiler are you using? C library? > > During the test, it returns the following error message: > > make[1]: Entering directory > '/home/stefanos/repositories/active/tinycc/tests' ------------ version > ------------ tcc version 0.9.28rc 2025-11-19 mob@7e4fc3a (x86_64 Linux) > ------------ hello-exe ------------ > Hello World > ------------ hello-run ------------ > Hello World > ------------ libtest ------------ > Hello World! > fib(32) = 2178309 > add(32, 64) = 96 > libtcc_test_mt.c: In function ‘sleep_ms’: > libtcc_test_mt.c:54:5: error: implicit declaration of function ‘usleep’; > did > you mean ‘sleep’? [-Wimplicit-function-declaration] 54 | usleep(n * > 1000); | ^~~~~~ > | sleep > make[2]: *** [Makefile:104: libtcc_test_mt] Error 1 > make[1]: *** [Makefile:84: all] Error 2 > make[1]: Leaving directory > '/home/stefanos/repositories/active/tinycc/tests' > make: *** [Makefile:457: test] Error 2 some background information: usleep was in POSIX, and it has been removed from the standard its usage was already discouraged in 1997: https://pubs.opengroup.org/onlinepubs/7908799/xsh/usleep.html latest edition, for reference: https://pubs.opengroup.org/onlinepubs/9799919799/ hence there is a bit of a #ifdef mess in unistd.h headers that support multiple versions of POSIX > > I opened tests/libtcc_test_mt.c file and saw there's a <unistd.h> header file > which is responsible for `usleep()`. > > To verify it got parsed as expected, I run > > tcc -E -P tests/libtcc_test_mt.c | grep usleep > > which indeed it returned > > extern int usleep (__useconds_t __useconds); > > The same error remains as it with `-std=c11` too. > > Can someone help me figuring out what am I doing wrong here? solution: use std=gnu99, usleep is an extension to the unistd.h header (can also be done with a #define of _XOPEN_SOURCE to certain value) make distclean; make clean; ./configure --extra-cflags='-std=gnu' && make -j$(nproc) && make test reproduction: this couldn't reproduce it (backtrace compilation is broken on musl, hence disabled) - and it couldn't on glibc, either: make distclean; make clean; ./configure --config-backtrace=no --extra-cflags='-std=c99' && make -j$(nproc) && make test a retry on glibc, this time make distclean; make clean; ./configure --config-backtrace=yes --extra-cflags='-std=c99' && make -j$(nproc) && make test reproduces the error: add(32, 64) = 96 libtcc_test_mt.c:54:5: error: call to undeclared function 'usleep'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 54 | usleep(n * 1000); | ^ libtcc_test_mt.c:54:5: note: did you mean 'sleep'? /usr/include/unistd.h:464:21: note: 'sleep' declared here 464 | extern unsigned int sleep (unsigned int __seconds); | ^ 1 error generated. make[2]: *** [Makefile:104: libtcc_test_mt] Error 1 make[1]: *** [Makefile:84: all] Error 2 make[1]: Leaving directory '/tmp/jeans/tinycc/tests' make: *** [Makefile:457: test] Error 2
signature.asc
Description: PGP signature
_______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
