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 errors after ./configure -a #71

Closed shuang886 closed 8 months ago

shuang886 commented 8 months ago

Hi, just want to make sure I'm not missing something glaringly obvious...

I'm trying to build just the library on macOS, so:

% ./configure -a
Testing for FreeBSD...
Not on FreeBSD. Using _POSIX_C_SOURCE and _XOPEN_SOURCE.

Testing for Mac OSX...
On Mac OSX. Using _DARWIN_C_SOURCE.

Testing for OpenBSD...
Not on OpenBSD.

Version: 6.7.2
Building bc
Building dc

BC_ENABLE_LIBRARY=1

BC_ENABLE_HISTORY=0
BC_ENABLE_EXTRA_MATH=1
BC_ENABLE_NLS=0

BC_ENABLE_AFL=0

BC_NUM_KARATSUBA_LEN=32

CC=c99
CFLAGS= -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0
HOSTCC=c99
HOSTCFLAGS=
CPPFLAGS=-DNDEBUG  -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
LDFLAGS=-s 
PREFIX=/usr/local
BINDIR=/usr/local/bin
INCLUDEDIR=/usr/local/include
LIBDIR=/usr/local/lib
DATAROOTDIR=/usr/local/share
DATADIR=/usr/local/share
MANDIR=/usr/local/share/man
MAN1DIR=/usr/local/share/man/man1
MAN3DIR=/usr/local/share/man/man3
NLSPATH=
PC_PATH=/opt/homebrew/lib/pkgconfig
EXECSUFFIX=
EXECPREFIX=
DESTDIR=
LONG_BIT=
GEN_HOST=1
GEN_EMU=

Setting Defaults
================
bc.banner=0
bc.sigint_reset=1
dc.sigint_reset=1
bc.tty_mode=1
dc.tty_mode=0
bc.prompt=1
dc.prompt=0
bc.expr_exit=1
dc.expr_exit=1
bc.digit_clamp=0
dc.digit_clamp=0

seems to be happy, but it doesn't actually build:

% make
mkdir -p bin
c99 -DBC_ENABLED=1 -DDC_ENABLED=1 -I./include/ -DBUILD_TYPE=HN  -DEXECPREFIX= -DMAINEXEC=bc  -D_DARWIN_C_SOURCE -DBC_NUM_KARATSUBA_LEN=32 -DBC_ENABLE_NLS=0 -DBC_ENABLE_EXTRA_MATH=1 -DBC_ENABLE_HISTORY=0 -DBC_ENABLE_LIBRARY=1 -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  -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0 -o src/args.o -c ./src//args.c
./src//args.c:62:6: error: use of undeclared identifier 'vm'
        if (vm->exprs.v == NULL)
            ^
./src//args.c:64:16: error: use of undeclared identifier 'vm'
                bc_vec_init(&vm->exprs, sizeof(uchar), BC_DTOR_NONE);
                             ^
...lots more...

vm appears to be defined in src/vm.c but inside a #if !BC_ENABLE_LIBRARY, while a lot of code in src/args.c are not correspondingly enclosed. I tried to sprinkle in some #if !BC_ENABLE_LIBRARY directives but that just exposed more code that needed to be #ifdefed out.

Building the executables (i.e., just plain ./configure) compiles and runs fine.

Would you mind clarifying if there's more needed than ./configure -a? I couldn't find anything that helps in the build manual, and I get the sense that args.c should not have been in the Makefile at all...

Thanks!

gavinhoward commented 8 months ago

You're not missing something glaringly obvious. That is a bug because it should build with no errors.

I think I fixed it in 7807eead159b80b51b8c81680608f8187284971e; can you pull and test for me?

If that is the fix, then the problem was an extra slash in a path; apparently Mac OSX does not clean paths when doing a string comparison. Oops.

shuang886 commented 8 months ago

Works now, thanks!

gavinhoward commented 8 months ago

You're welcome. I'll put out a new release with the fix.

gavinhoward commented 8 months ago

Ah! I made a mistake! Could you pull 7eaa40ab8cac29893155471076c621c2f9929d33 and see if that works?

shuang886 commented 8 months ago

Yup, still works.

gavinhoward commented 8 months ago

Thank you, and I'm sorry.