> which compiler are you using? C library?

I'm using GCC 15.2.0, GNU / Linux Debian testing 64-bit.


> 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

True, I have found this information after I sent the email...I should have
investigated even more before sending an email!


> which compiler are you using? C library?

I'm using GCC 15.2.0, GNU / Linux Debian testing 64-bit.

> 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

True, I have found this information after I sent the email...I should have
investigated even more before sending an email!

> 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
> 

Indeed, I have tried this after I have added manually
`-Wall -Wextra -O2 -std=gnu11` in config.mak and rerun the whole process; it
worked as expected with a number of warnings of course about unused 
parameters and comparing signed values with unsigned etc.

> 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

So, is it something that we need to do to fix this erratic behavior or is it
something that's expected?

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to