From 792463cb133f65645feb48743bbc03ef8eb96bdd Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Tue, 13 Sep 2022 21:46:21 +0100 Subject: Move towards C23, improve events and vcall macros Another big one. Here's a list of things: - Since the upcoming C23 standardises typeof(), use it as an extension for the time being in order to allow passing arbitrary types as macro/codegen parameters. It wouldn't have been a big leap to do this even without standardisation since it's apparently an easy extension to implement - and also, to be honest, this project is essentially glued to Clang anyway so who cares. - Likewise, bool, true and false are becoming pre-defined, so pre-pre-define them now in order to get the benefit of not having to remember one header everywhere. - Really ungodly/amazing vcall macro stuff now allows us to call C++ virtual functions like regular C functions. It's pretty cool! - Events can now take arbitrary parameters and come in two types: regular events and predicates. All this makes the base code even uglier but makes the feature implementation nicer. In other words, it places more of the cognitive burden on myself and less on other people who might want to contribute. This is a good tradeoff, because I'm a genius. --- compile | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'compile') diff --git a/compile b/compile index b2aa205..3c35ed1 100755 --- a/compile +++ b/compile @@ -3,10 +3,14 @@ case "`uname -s`" in # weird people using Windows Bash might type ./compile, help them out :) - *NT*) - echo "You're on Windows, idiot! Running compile.bat for you." + *NT*) # msys2 or busybox-w32 + echo "You're on Windows, idiot! Running compile.bat for you.">&2 exec cmd /c compile.bat ;; esac +case "`uname -r`" in + *Microsoft*) + echo "NOTE: building inside WSL. Use compile.bat to build for Windows!">&2 +esac mkdir -p .build/include @@ -33,8 +37,10 @@ cc() { # ugly annoying special case if [ "$_mn" = " -DMODULE_NAME=con_" ]; then _mn=" -DMODULE_NAME=con" elif [ "$_mn" = "-DMODULE_NAME=sst" ]; then _mn=; fi + # note: using typeof and bool from C23 - see detailed comment in compile.bat $CC -m32 -c -flto -fpic $cflags $warnings -I.build/include \ - -D_FILE_OFFSET_BITS=64$_mn -o ".build/${_bn%%.c}.o" "src/$1" + -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64$_mn \ + -Dtypeof=__typeof -include stdbool.h -o ".build/${_bn%%.c}.o" "src/$1" } ld() { @@ -71,12 +77,12 @@ if [ "$dbg" = 1 ]; then src="$src \ udis86.c" fi -$HOSTCC -O2 -fuse-ld=lld $warnings -D_FILE_OFFSET_BITS=64 -o .build/codegen \ - src/build/codegen.c src/build/cmeta.c -$HOSTCC -O2 -fuse-ld=lld $warnings -D_FILE_OFFSET_BITS=64 -o .build/mkgamedata \ - src/build/mkgamedata.c src/kv.c -$HOSTCC -O2 -fuse-ld=lld $warnings -D_FILE_OFFSET_BITS=64 -o .build/mkentprops \ - src/build/mkentprops.c src/kv.c +$HOSTCC -O2 -fuse-ld=lld $warnings -D_FILE_OFFSET_BITS=64 -include stdbool.h \ + -o .build/codegen src/build/codegen.c src/build/cmeta.c +$HOSTCC -O2 -fuse-ld=lld $warnings -D_FILE_OFFSET_BITS=64 -include stdbool.h \ + -o .build/mkgamedata src/build/mkgamedata.c src/kv.c +$HOSTCC -O2 -fuse-ld=lld $warnings -D_FILE_OFFSET_BITS=64 -include stdbool.h \ + -o .build/mkentprops src/build/mkentprops.c src/kv.c .build/codegen `for s in $src; do echo "src/$s"; done` .build/mkgamedata gamedata/engine.kv gamedata/gamelib.kv gamedata/inputsystem.kv .build/mkentprops gamedata/entprops.kv -- cgit v1.2.3