From: bones_was_here Date: Thu, 11 Apr 2024 17:55:08 +0000 (+1000) Subject: build: minor adjustments X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;ds=sidebyside;h=71e366e8129cb97bda348fa9bf86727c5e7887c7;p=xonotic%2Fdarkplaces.git build: minor adjustments VS2019: get more of the targets to build (needed to specify modern C standard for all of them, and SDK "10.0" seems to mean "use latest version installed"). VS2019: improve README.md instructions. Makefile: fix PEDANTIC=1 test builds and warning spam. sys: properly fix warnings related to SDL's wrapping of main() for all platforms. Signed-off-by: bones_was_here --- diff --git a/README.md b/README.md index acb53919..df037d5c 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ These instructions are adequate for Quake, but for Xonotic please refer to [its ### Required packages The minimum SDL version is 2.0.18 for Linux and 2.24.0 for Windows. +The supported compilers are GCC and Clang. The following package names are for Debian, see below for Windows and Mac. ##### Client @@ -96,19 +97,16 @@ If you get errors (that don't seem to be about missing dependencies) try `make c Not recommended due to poor support for C standards, and lack of maintenance. -DarkPlaces requires C11, so Windows SDK 10.0.22000.0 (VS 2019) or 10.0.20348.0 (VS 2022) or later is needed. -To install it, run the Visual Studio Installer, click "Modify", click "Individual components", select the latest Windows SDK version and de-select older versions. -You will also need the NuGet Package Manager selected (to download SDL2 headers the first time you build). +DarkPlaces requires C11, so Windows SDK 10.0.20348.0 or later is needed. +To install it, run the Visual Studio Installer, click "Modify", click "Individual components", type "Windows SDK" in the search box, select the latest Windows SDK and de-select older versions. +You will also need "NuGet package manager" selected (to download SDL2 headers the first time you build). Click "Modify" to apply the changes. -VS 2019 -![MSVC2019](msvc2019_C11.png) +Open `darkplaces-vs2019.sln`, select build type (`Debug` or `Release`) and platform (`Win32` or `x64`), and choose "Build Solution" from the "Build" menu to create files `darkplaces-sdl2-vs2019.exe` and `SDL2.dll`. -Open `darkplaces-vs2019.sln`, select build type "Debug" or "Release, and choose "Build Solution" from the "Build" menu to create the file `darkplaces-sdl2-vs2019.exe`. +The Release build crashes. The Debug x64 build doesn't crash (but is rather slow) so this will be Fun for someone to debug. -The Release build crashes. The Debug build doesn't crash (but is rather slow) so this will be Fun for someone to debug. - -To get a build suitable for playing Quake you'll need to use MinGW gcc, or download the autobuild from Xonotic (see above). +To get a build suitable for playing you'll need to use MinGW GCC, or download the autobuild from Xonotic (see above). ## Contributing diff --git a/darkplaces-sdl2-vs2019.vcxproj b/darkplaces-sdl2-vs2019.vcxproj index d2cd07e2..f94592a5 100644 --- a/darkplaces-sdl2-vs2019.vcxproj +++ b/darkplaces-sdl2-vs2019.vcxproj @@ -23,30 +23,30 @@ darkplacessdl2 Win32Proj darkplaces-sdl2-vs2019 - 10.0.22000.0 + 10.0 Application - v142 MultiByte true + v142 Application - v142 MultiByte + v142 Application - v142 MultiByte true + v142 Application - v142 MultiByte + v142 @@ -88,6 +88,8 @@ 4706;4127;4100;4055;4054;4244;4305;4702;%(DisableSpecificWarnings) true /wd"4201" %(AdditionalOptions) + stdcpp17 + stdc17 $(OutDir)$(TargetName)$(TargetExt) @@ -139,6 +141,8 @@ 4706;4127;4100;4055;4054;4244;4305;4702;%(DisableSpecificWarnings) true /wd"4201" %(AdditionalOptions) + stdcpp17 + stdc17 $(OutDir)$(TargetName)$(TargetExt) diff --git a/docs/msvc2019_C11.png b/docs/msvc2019_C11.png deleted file mode 100644 index 59266364..00000000 Binary files a/docs/msvc2019_C11.png and /dev/null differ diff --git a/makefile.inc b/makefile.inc index ab30eeb6..dc9c990e 100644 --- a/makefile.inc +++ b/makefile.inc @@ -131,8 +131,10 @@ OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o thread_sdl.o $(OBJ_MENU) $(OBJ_SND_COMM # Compilation +# -D_POSIX_C_SOURCE=200809L doesn't enable all of POSIX 2008, wtf? +# -D_DEFAULT_SOURCE does enables all of POSIX 2008 (without GNU extensions). ifeq ($(PEDANTIC),1) - CFLAGS_STANDARD=-std=c11 -pedantic -D_POSIX_C_SOURCE=200809L -DCONFIG_PEDANTIC + CFLAGS_STANDARD=-std=c17 -pedantic -D_DEFAULT_SOURCE -DCONFIG_PEDANTIC else CFLAGS_STANDARD= endif diff --git a/protocol.h b/protocol.h index 5a747a05..92b98dba 100644 --- a/protocol.h +++ b/protocol.h @@ -28,9 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "qstats.h" struct mempool_s; struct sizebuf_s; -// protocolversion_t is defined in common.h -enum protocolversion_e; +// protocolversion_t is defined in common.h enum protocolversion_e Protocol_EnumForName(const char *s); const char *Protocol_NameForEnum(enum protocolversion_e p); enum protocolversion_e Protocol_EnumForNumber(int n); diff --git a/sys.h b/sys.h index 2f21159f..a5c6b275 100644 --- a/sys.h +++ b/sys.h @@ -261,5 +261,7 @@ void Sys_InitProcessNice (void); void Sys_MakeProcessNice (void); void Sys_MakeProcessMean (void); +int Sys_Main(int argc, char *argv[]); + #endif diff --git a/sys_null.c b/sys_null.c index e2b9b0a0..bb288586 100644 --- a/sys_null.c +++ b/sys_null.c @@ -33,3 +33,8 @@ void Sys_SDL_Delay (unsigned int milliseconds) { Sys_Error("Called Sys_SDL_Delay on non-SDL target"); } + +int main(int argc, char *argv[]) +{ + return Sys_Main(argc, argv); +} diff --git a/sys_sdl.c b/sys_sdl.c index f96bc87e..574f1355 100644 --- a/sys_sdl.c +++ b/sys_sdl.c @@ -69,3 +69,8 @@ void Sys_SDL_Delay (unsigned int milliseconds) { SDL_Delay(milliseconds); } + +int main(int argc, char *argv[]) +{ + return Sys_Main(argc, argv); +} diff --git a/sys_shared.c b/sys_shared.c index 75179754..4222c42b 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -37,11 +37,6 @@ #include "taskqueue.h" #include "thread.h" #include "libcurl.h" -#if defined(_MSC_VER) - // Not sure why MS compiler needs this here and gcc doesn't... - // and gcc fails to build darkplaces-dedicated if it's included here. - #include "SDL.h" -#endif sys_t sys; @@ -1092,7 +1087,11 @@ static void Sys_InitSignals(void) #endif } -int main (int argc, char **argv) +/** main() but renamed so we can wrap it in sys_sdl.c and sys_null.c + * to avoid needing to include SDL.h in this file (would make the dedicated server require SDL). + * SDL builds need SDL.h in the file where main() is defined because SDL renames and wraps main(). + */ +int Sys_Main(int argc, char *argv[]) { sys.argc = argc; sys.argv = (const char **)argv;