adrian-thurston / colm

The Colm Programming Language
MIT License
164 stars 31 forks source link

src/bytecode.c: include config.h to activate guards #145

Open grobian opened 2 years ago

grobian commented 2 years ago

Fix compilation on Solaris, which needs sys/wait.h for macros like WEXITSTATUS.

Signed-off-by: Fabian Groffen grobian@gentoo.org

grobian commented 2 years ago

without this change:

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../src/aapl -Iinclude -Wall -g -MT bytecode.lo -MD -MP -MF .deps/bytecode.Tpo -c bytecode.c  -fPIC -DPIC -o .libs/bytecode.o
bytecode.c: In function ‘colm_execute_code’:
bytecode.c:3893:30: warning: implicit declaration of function ‘WIFSIGNALED’ [-Wimplicit-function-declaration]
 3893 |                         if ( WIFSIGNALED( res ) )
      |                              ^~~~~~~~~~~
bytecode.c:3894:40: warning: implicit declaration of function ‘WTERMSIG’ [-Wimplicit-function-declaration]
 3894 |                                 raise( WTERMSIG( res ) );
      |                                        ^~~~~~~~
bytecode.c:3895:31: warning: implicit declaration of function ‘WEXITSTATUS’ [-Wimplicit-function-declaration]
 3895 |                         res = WEXITSTATUS( res );
      |                               ^~~~~~~~~~~

...
libtool: link: g++ -Wall "-DINCLUDEDIR=\"/usr/local/include\"" "-DLIBDIR=\"/usr/local/lib\"" "-DABS_TOP_BUILDDIR=\"/net/ptah/export/gentoo/working-repos/colm\"" "-DABS_BUILDDIR=\"/net/ptah/export/gentoo/working-repos/colm/src\"" -DCONS_INIT -Wall -g -o .libs/bootstrap0 bootstrap0-consinit.o bootstrap0-main.o  -L. libprog.a ./.libs/libcolm.so -Wl,-rpath -Wl,/usr/local/lib
/gentoo/prefix64/usr/x86_64-pc-solaris2.11/binutils-bin/2.34/ld: ./.libs/libcolm.so: undefined reference to `WEXITSTATUS'
/gentoo/prefix64/usr/x86_64-pc-solaris2.11/binutils-bin/2.34/ld: ./.libs/libcolm.so: undefined reference to `WIFSIGNALED'
/gentoo/prefix64/usr/x86_64-pc-solaris2.11/binutils-bin/2.34/ld: ./.libs/libcolm.so: undefined reference to `WTERMSIG'
collect2: error: ld returned 1 exit status

This is just the only file that needs config.h's defines, but I guess if autoconf is being used to check for features, that actually all source files should include config.h first thing.

Anyway, I just did this single file, with it, everything compiles and links, resulting in:

% ./src/colm --version Colm version 0.14.7 February 2021 Copyright (c) 2007-2020 by Dr. Adrian D. Thurston