]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
build: minor adjustments master
authorbones_was_here <bones_was_here@xonotic.au>
Thu, 11 Apr 2024 17:55:08 +0000 (03:55 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Sun, 14 Apr 2024 16:24:08 +0000 (02:24 +1000)
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 <bones_was_here@xonotic.au>
README.md
darkplaces-sdl2-vs2019.vcxproj
docs/msvc2019_C11.png [deleted file]
makefile.inc
protocol.h
sys.h
sys_null.c
sys_sdl.c
sys_shared.c

index acb53919f6cdd8cda81beef150e49fded6741254..df037d5c395d915012a76c835b768496c7d7751f 100644 (file)
--- 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
index d2cd07e2536610ca132b4b208fd58a92438e90cd..f94592a577ef7ab37488a675c4ae16e78139d116 100644 (file)
     <RootNamespace>darkplacessdl2</RootNamespace>\r
     <Keyword>Win32Proj</Keyword>\r
     <ProjectName>darkplaces-sdl2-vs2019</ProjectName>\r
-    <WindowsTargetPlatformVersion>10.0.22000.0</WindowsTargetPlatformVersion>\r
+    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r
   </PropertyGroup>\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
     <ConfigurationType>Application</ConfigurationType>\r
-    <PlatformToolset>v142</PlatformToolset>\r
     <CharacterSet>MultiByte</CharacterSet>\r
     <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <PlatformToolset>v142</PlatformToolset>\r
   </PropertyGroup>\r
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
     <ConfigurationType>Application</ConfigurationType>\r
-    <PlatformToolset>v142</PlatformToolset>\r
     <CharacterSet>MultiByte</CharacterSet>\r
+    <PlatformToolset>v142</PlatformToolset>\r
   </PropertyGroup>\r
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
     <ConfigurationType>Application</ConfigurationType>\r
-    <PlatformToolset>v142</PlatformToolset>\r
     <CharacterSet>MultiByte</CharacterSet>\r
     <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <PlatformToolset>v142</PlatformToolset>\r
   </PropertyGroup>\r
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
     <ConfigurationType>Application</ConfigurationType>\r
-    <PlatformToolset>v142</PlatformToolset>\r
     <CharacterSet>MultiByte</CharacterSet>\r
+    <PlatformToolset>v142</PlatformToolset>\r
   </PropertyGroup>\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
   <ImportGroup Label="ExtensionSettings">\r
@@ -88,6 +88,8 @@
       <DisableSpecificWarnings>4706;4127;4100;4055;4054;4244;4305;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings>\r
       <MultiProcessorCompilation>true</MultiProcessorCompilation>\r
       <AdditionalOptions>/wd"4201" %(AdditionalOptions)</AdditionalOptions>\r
+      <LanguageStandard>stdcpp17</LanguageStandard>\r
+      <LanguageStandard_C>stdc17</LanguageStandard_C>\r
     </ClCompile>\r
     <Link>\r
       <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r
       <DisableSpecificWarnings>4706;4127;4100;4055;4054;4244;4305;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings>\r
       <MultiProcessorCompilation>true</MultiProcessorCompilation>\r
       <AdditionalOptions>/wd"4201" %(AdditionalOptions)</AdditionalOptions>\r
+      <LanguageStandard>stdcpp17</LanguageStandard>\r
+      <LanguageStandard_C>stdc17</LanguageStandard_C>\r
     </ClCompile>\r
     <Link>\r
       <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r
diff --git a/docs/msvc2019_C11.png b/docs/msvc2019_C11.png
deleted file mode 100644 (file)
index 5926636..0000000
Binary files a/docs/msvc2019_C11.png and /dev/null differ
index ab30eeb69c1e6f2b37d1d2762e40c4073b662673..dc9c990e31dab1754b8e40414b320db135f98ed4 100644 (file)
@@ -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
index 5a747a050a61ee55430764807696514ec402c0dc..92b98dba248374ee33ee479a07bae0f8a663e69b 100644 (file)
@@ -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 2f21159f1e3cf6c14427e6b95195c67b9fd233a6..a5c6b275b2e08d9d2c5e2d45251d4c8a1e3d5e11 100644 (file)
--- 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
 
index e2b9b0a0876e18834dffbb7bc545d52f98cac41b..bb2885867f22af7d6945069cfbf7c38bf0c352d5 100644 (file)
@@ -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);
+}
index f96bc87eabfc7aa5dc15177c0e9f3b6f77477a39..574f1355aacedb76cb10b57d497f29c910effe8b 100644 (file)
--- 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);
+}
index 751797540951117a6b8cfdc73659da1ecab1c324..4222c42be414c88836cdfe48a87c73993482b554 100644 (file)
 #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;