SirWumpus / post4

Post4 is an indirect threaded Forth dialect written in C.
BSD 2-Clause "Simplified" License
4 stars 1 forks source link

Compile error: use of undeclared identifier 'SIGWINCH' #36

Closed tcort closed 1 month ago

tcort commented 1 month ago

Error:

post4.c:167:9: error: use of undeclared identifier 'SIGWINCH'
        signal(SIGWINCH, sig_winch);
               ^
post4.c:207:12: error: use of undeclared identifier 'SIGWINCH'
        sig_winch(SIGWINCH);
                  ^

system:

Darwin megatron.local 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 arm64

compiler:

Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

The definition is hidden behind feature check macros in signal.h:

#if  (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
#define SIGWINCH 28     /* window size changes */
#define SIGINFO 29      /* information request */
#endif

If I add -D_DARWIN_C_SOURCE to CFLAGS the project builds and all tests pass:

Total Pass 1462 Fail 0 Skip 0
JNI support disabled.
Total Pass 0 Fail 0 Skip 0

Adding the following to src/post4.h allows it to compile on macOS 14.6.1/arm64:

#if defined (__APPLE__)
#define _DARWIN_C_SOURCE 1
#endif 
SirWumpus commented 1 month ago

Thank you.