gavinhoward / bc

An implementation of the POSIX bc calculator with GNU extensions and dc, moved away from GitHub. Finished, but well-maintained.
https://git.gavinhoward.com/gavin/bc
Other
145 stars 29 forks source link

Build fails on macOS #67

Closed mhorowitz closed 1 year ago

mhorowitz commented 1 year ago

platform: MacOS Ventura 13.2.1 (m1 max) compiler: c99 from Xcode 14.2.0 version: https://git.gavinhoward.com/gavin/bc.git 55a6c05b280fbfb6873e42a5825403c17417029a

Build fails:

$ ./configure -O3
<success>
$ make
c99 -DBC_ENABLED=1 -DDC_ENABLED=1 -I./include/ -DBUILD_TYPE=A  -DEXECPREFIX= -DMAINEXEC=bc  -DBC_NUM_KARATSUBA_LEN=32 -DBC_ENABLE_NLS=1 -DBC_ENABLE_EXTRA_MATH=1 -DBC_ENABLE_HISTORY=1 -DBC_ENABLE_LIBRARY=0 -DBC_ENABLE_MEMCHECK=0 -DBC_ENABLE_AFL=0 -DBC_DEFAULT_BANNER=0 -DBC_DEFAULT_SIGINT_RESET=1 -DBC_DEFAULT_TTY_MODE=1 -DBC_DEFAULT_PROMPT=1 -DBC_DEFAULT_EXPR_EXIT=1 -DBC_DEFAULT_DIGIT_CLAMP=0 -DDC_DEFAULT_SIGINT_RESET=1 -DDC_DEFAULT_TTY_MODE=0 -DDC_DEFAULT_PROMPT=0 -DDC_DEFAULT_EXPR_EXIT=1 -DDC_DEFAULT_DIGIT_CLAMP=0 -DNDEBUG  -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -O3  -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0 -o src/program.o -c ./src//program.c
./src//program.c:2994:6: error: use of undeclared identifier 'SIGWINCH'
        if (BC_SIG_INTERRUPT(vm))
            ^
./include/status.h:698:45: note: expanded from macro 'BC_SIG_INTERRUPT'
        BC_UNLIKELY((vm)->sig != 0 && (vm)->sig != SIGWINCH)
                                                   ^
./src//program.c:3724:6: error: use of undeclared identifier 'SIGWINCH'
        if (BC_SIG_INTERRUPT(vm))
            ^
./include/status.h:698:45: note: expanded from macro 'BC_SIG_INTERRUPT'
        BC_UNLIKELY((vm)->sig != 0 && (vm)->sig != SIGWINCH)
                                                   ^
2 errors generated.
make: *** [src/program.o] Error 1

I think ideally, configure.sh would detect this, and apply an appropriate set of flags, or the source would be changed appropriately.

As a workaround, this allows a successful build:

CFLAGS=-D_DARWIN_C_SOURCE ./configure -O3
gavinhoward commented 1 year ago

Stupid GitHub, closing the issue just because I mention the number in a commit...

Anyway, yes, this is a bug, and yes, configure.sh should detect this.

I've added 29b4b6a4f27b07c4a176258aaf831a5208d4e116 in an attempt to fix this. Unfortunately, I don't have a Mac, so you'll need to test this for me. Would you please do that? Thank you.

mhorowitz commented 1 year ago

I've added https://github.com/gavinhoward/bc/commit/29b4b6a4f27b07c4a176258aaf831a5208d4e116 in an attempt to fix this. Unfortunately, I don't have a Mac, so you'll need to test this for me. Would you please do that? Thank you.

I tested it. ./configure.sh output includes

On Mac OSX. Using _DARWIN_C_SOURCE.

And make completes without error. Thanks for the quick fix!

gavinhoward commented 1 year ago

Thank you for testing! And thank you for the report. I rely on users like you to help me with Mac OSX!

gavinhoward commented 1 year ago

Release 6.6.0 is out with the fix. Thank you!