Make it compile in visual studio again, without warnings.
authorDale Weiler <killfieldengine@gmail.com>
Fri, 16 Aug 2013 09:03:36 +0000 (09:03 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Fri, 16 Aug 2013 09:03:36 +0000 (09:03 +0000)
16 files changed:
exec.c
ftepp.c
include.mk
intrin.c
msvc/gmqcc/gmqcc.vcxproj
msvc/gmqcc/gmqcc.vcxproj.filters
msvc/pak/pak.vcxproj
msvc/pak/pak.vcxproj.filters
msvc/qcvm/qcvm.vcxproj
msvc/qcvm/qcvm.vcxproj.filters
msvc/testsuite/testsuite.vcxproj
msvc/testsuite/testsuite.vcxproj.filters
opts.c
parser.c
stat.c
test.c

diff --git a/exec.c b/exec.c
index de917db4f896ae4b7202761895f229c92c00baf8..33037dcda74bf299487c358679ba82ce7984f4be 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -30,6 +30,7 @@
 
 #include "gmqcc.h"
 
+opts_cmd_t   opts; /* command line options */
 static void loaderror(const char *fmt, ...)
 {
     int     err = errno;
diff --git a/ftepp.c b/ftepp.c
index a28bbec862720fa75dacdbb0e0dd9c4a1212a3bb..8edb644f8c44019eeee11f43ee8b6e2f20d39d07 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -183,6 +183,9 @@ static char *ftepp_predef_timestamp(lex_file *context) {
     char       *find;
     char       *value;
     size_t      size;
+#ifdef _MSC_VER
+       char        buffer[64];
+#endif
     if (stat(context->name, &finfo))
         return util_strdup("\"<failed to determine timestamp>\"");
 
@@ -190,7 +193,14 @@ static char *ftepp_predef_timestamp(lex_file *context) {
      * ctime and its fucking annoying newline char, no worries, we're
      * professionals here.
      */
+
+#ifndef _MSC_VER
     find  = ctime(&finfo.st_mtime);
+#else
+       ctime_s(buffer, sizeof(buffer), &finfo.st_mtime);
+       find = buffer;
+#endif
+
     value = (char*)mem_a(strlen(find) + 1);
     memcpy(&value[1], find, (size = strlen(find)) - 1);
 
index a1d7430edb961b56ec34c34e7b485965817691c6..f4b118b7c0630a165bef4651b3319d7a68b25a26 100644 (file)
@@ -16,7 +16,7 @@ LIBS    += -lm
 #objects
 OBJ_C = main.o lexer.o parser.o fs.o stat.o util.o code.o ast.o ir.o conout.o ftepp.o opts.o utf8.o correct.o fold.o intrin.o
 OBJ_P = util.o fs.o conout.o opts.o pak.o stat.o
-OBJ_T = test.o util.o opts.o conout.o fs.o stat.o
+OBJ_T = test.o util.o conout.o fs.o stat.o
 OBJ_X = exec-standalone.o util.o opts.o conout.o fs.o stat.o
 
 #gource flags
index 26012e78765757dea350ac81e7dd59d0233a962d..30c7424ccae533954b26d966551952a40e5d7dfe 100644 (file)
--- a/intrin.c
+++ b/intrin.c
@@ -57,7 +57,7 @@
         vec_push(intrin->parser->globals,   (ast_expression*)(VALUE)); \
     } while (0)
 
-#define QC_M_E 2.71828182845905
+#define QC_M_E 2.71828182845905f
 
 static ast_expression *intrin_pow (intrin_t *intrin) {
     /*
index f184b3bc860dc0b42de89283881d4fe563d19c70..8335978d05c68dce5840ee9b231939cb3db06290 100755 (executable)
       <Platform>Win32</Platform>\r
     </ProjectConfiguration>\r
   </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\ast.c" />\r
+    <ClCompile Include="..\..\code.c" />\r
+    <ClCompile Include="..\..\conout.c" />\r
+    <ClCompile Include="..\..\correct.c" />\r
+    <ClCompile Include="..\..\fold.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\ftepp.c" />\r
+    <ClCompile Include="..\..\intrin.c" />\r
+    <ClCompile Include="..\..\ir.c" />\r
+    <ClCompile Include="..\..\lexer.c" />\r
+    <ClCompile Include="..\..\main.c" />\r
+    <ClCompile Include="..\..\opts.c" />\r
+    <ClCompile Include="..\..\parser.c" />\r
+    <ClCompile Include="..\..\stat.c" />\r
+    <ClCompile Include="..\..\utf8.c" />\r
+    <ClCompile Include="..\..\util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\ast.h" />\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
+    <ClInclude Include="..\..\ir.h" />\r
+    <ClInclude Include="..\..\lexer.h" />\r
+    <ClInclude Include="..\..\parser.h" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="..\..\opts.def" />\r
+  </ItemGroup>\r
   <PropertyGroup Label="Globals">\r
     <ProjectGuid>{A6BD74E1-31BB-4D00-A9E0-09FF1BC76ED6}</ProjectGuid>\r
     <RootNamespace>gmqcc</RootNamespace>\r
@@ -41,6 +69,7 @@
     <ClCompile>\r
       <WarningLevel>Level3</WarningLevel>\r
       <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>NVALGRIND;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
     </ClCompile>\r
     <Link>\r
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
@@ -52,6 +81,7 @@
       <Optimization>MaxSpeed</Optimization>\r
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
       <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>NVALGRIND;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
     </ClCompile>\r
     <Link>\r
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
       <OptimizeReferences>true</OptimizeReferences>\r
     </Link>\r
   </ItemDefinitionGroup>\r
-  <ItemGroup>\r
-    <ClCompile Include="..\..\ast.c" />\r
-    <ClCompile Include="..\..\code.c" />\r
-    <ClCompile Include="..\..\conout.c" />\r
-    <ClCompile Include="..\..\correct.c" />\r
-    <ClCompile Include="..\..\fs.c" />\r
-    <ClCompile Include="..\..\ftepp.c" />\r
-    <ClCompile Include="..\..\ir.c" />\r
-    <ClCompile Include="..\..\lexer.c" />\r
-    <ClCompile Include="..\..\main.c" />\r
-    <ClCompile Include="..\..\opts.c" />\r
-    <ClCompile Include="..\..\parser.c" />\r
-    <ClCompile Include="..\..\utf8.c" />\r
-    <ClCompile Include="..\..\util.c" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ClInclude Include="..\..\ast.h" />\r
-    <ClInclude Include="..\..\gmqcc.h" />\r
-    <ClInclude Include="..\..\intrin.h" />\r
-    <ClInclude Include="..\..\ir.h" />\r
-    <ClInclude Include="..\..\lexer.h" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <None Include="..\..\opts.def" />\r
-  </ItemGroup>\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
   <ImportGroup Label="ExtensionTargets">\r
   </ImportGroup>\r
index 9272e9ffc42377a6c7daa5eb330af31f879480c9..7797df3443e77164d27c6e13650d298b43d33350 100755 (executable)
@@ -5,22 +5,25 @@
     <ClCompile Include="..\..\code.c" />\r
     <ClCompile Include="..\..\conout.c" />\r
     <ClCompile Include="..\..\correct.c" />\r
+    <ClCompile Include="..\..\fold.c" />\r
     <ClCompile Include="..\..\fs.c" />\r
     <ClCompile Include="..\..\ftepp.c" />\r
+    <ClCompile Include="..\..\intrin.c" />\r
     <ClCompile Include="..\..\ir.c" />\r
     <ClCompile Include="..\..\lexer.c" />\r
     <ClCompile Include="..\..\main.c" />\r
     <ClCompile Include="..\..\opts.c" />\r
     <ClCompile Include="..\..\parser.c" />\r
+    <ClCompile Include="..\..\stat.c" />\r
     <ClCompile Include="..\..\utf8.c" />\r
     <ClCompile Include="..\..\util.c" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="..\..\ast.h" />\r
     <ClInclude Include="..\..\gmqcc.h" />\r
-    <ClInclude Include="..\..\intrin.h" />\r
     <ClInclude Include="..\..\ir.h" />\r
     <ClInclude Include="..\..\lexer.h" />\r
+    <ClInclude Include="..\..\parser.h" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <None Include="..\..\opts.def" />\r
index ab075a90ebbb9a7dc50d4d7b2d685e7f5c44f672..4ab71bf59f7b7429ac44afbb658aa32fe9fe23ff 100755 (executable)
       <Platform>Win32</Platform>\r
     </ProjectConfiguration>\r
   </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\conout.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\opts.c" />\r
+    <ClCompile Include="..\..\pak.c" />\r
+    <ClCompile Include="..\..\stat.c" />\r
+    <ClCompile Include="..\..\util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="..\..\opts.def" />\r
+  </ItemGroup>\r
   <PropertyGroup Label="Globals">\r
     <ProjectGuid>{A6F66BE9-57EF-4E93-AA9D-6E0C8B0990AD}</ProjectGuid>\r
     <RootNamespace>pak</RootNamespace>\r
@@ -41,6 +55,7 @@
     <ClCompile>\r
       <WarningLevel>Level3</WarningLevel>\r
       <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>NVALGRIND;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
     </ClCompile>\r
     <Link>\r
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
@@ -52,6 +67,7 @@
       <Optimization>MaxSpeed</Optimization>\r
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
       <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>NVALGRIND;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
     </ClCompile>\r
     <Link>\r
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
       <OptimizeReferences>true</OptimizeReferences>\r
     </Link>\r
   </ItemDefinitionGroup>\r
-  <ItemGroup>\r
-    <ClCompile Include="..\..\conout.c" />\r
-    <ClCompile Include="..\..\fs.c" />\r
-    <ClCompile Include="..\..\opts.c" />\r
-    <ClCompile Include="..\..\pak.c" />\r
-    <ClCompile Include="..\..\util.c" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <None Include="..\..\opts.def" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ClInclude Include="..\..\gmqcc.h" />\r
-  </ItemGroup>\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
   <ImportGroup Label="ExtensionTargets">\r
   </ImportGroup>\r
index 745f4ce64ad1688fa284a1ec3bdaebb212264b80..8784b71334f9f8e057b94164007522819eb1f028 100755 (executable)
@@ -5,12 +5,13 @@
     <ClCompile Include="..\..\fs.c" />\r
     <ClCompile Include="..\..\opts.c" />\r
     <ClCompile Include="..\..\pak.c" />\r
+    <ClCompile Include="..\..\stat.c" />\r
     <ClCompile Include="..\..\util.c" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <None Include="..\..\opts.def" />\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <ClInclude Include="..\..\gmqcc.h" />\r
+    <None Include="..\..\opts.def" />\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file
index 8892daace7af832285fc58f8079a3c6fbdb65f51..c7ce04fd089447aef928f032df49a15a395b5934 100755 (executable)
       <Platform>Win32</Platform>\r
     </ProjectConfiguration>\r
   </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\conout.c" />\r
+    <ClCompile Include="..\..\exec.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\stat.c" />\r
+    <ClCompile Include="..\..\util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
+  </ItemGroup>\r
   <PropertyGroup Label="Globals">\r
     <ProjectGuid>{DC980E20-C7A8-4112-A517-631DBDA788E7}</ProjectGuid>\r
     <RootNamespace>qcvm</RootNamespace>\r
@@ -41,7 +51,7 @@
     <ClCompile>\r
       <WarningLevel>Level3</WarningLevel>\r
       <Optimization>Disabled</Optimization>\r
-      <PreprocessorDefinitions>QCVM_EXECUTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>NVALGRIND;QCVM_EXECUTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
     </ClCompile>\r
     <Link>\r
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
@@ -53,7 +63,7 @@
       <Optimization>MaxSpeed</Optimization>\r
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
       <IntrinsicFunctions>true</IntrinsicFunctions>\r
-      <PreprocessorDefinitions>QCVM_EXECUTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>NVALGRIND;QCVM_EXECUTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
     </ClCompile>\r
     <Link>\r
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
       <OptimizeReferences>true</OptimizeReferences>\r
     </Link>\r
   </ItemDefinitionGroup>\r
-  <ItemGroup>\r
-    <ClCompile Include="..\..\conout.c" />\r
-    <ClCompile Include="..\..\exec.c" />\r
-    <ClCompile Include="..\..\fs.c" />\r
-    <ClCompile Include="..\..\util.c" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ClInclude Include="..\..\gmqcc.h" />\r
-  </ItemGroup>\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
   <ImportGroup Label="ExtensionTargets">\r
   </ImportGroup>\r
index 526cd892bbcea17a78eb6a29a409d685b058f731..cbdf8a30b222659383ac6e9b3793b0ca00ac4374 100755 (executable)
@@ -3,8 +3,9 @@
   <ItemGroup>\r
     <ClCompile Include="..\..\conout.c" />\r
     <ClCompile Include="..\..\exec.c" />\r
-    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\stat.c" />\r
     <ClCompile Include="..\..\util.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="..\..\gmqcc.h" />\r
index f0207f9e7ee72f83d4ab2fd933dddb97ac6b937c..bad2db1113a1546b8c709e0fbc0c5637575d8783 100755 (executable)
       <Platform>Win32</Platform>\r
     </ProjectConfiguration>\r
   </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\conout.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\opts.c" />\r
+    <ClCompile Include="..\..\stat.c" />\r
+    <ClCompile Include="..\..\test.c" />\r
+    <ClCompile Include="..\..\util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="..\..\opts.def" />\r
+  </ItemGroup>\r
   <PropertyGroup Label="Globals">\r
     <ProjectGuid>{7E2839D9-9C1A-4489-9FF9-FDC854EBED3D}</ProjectGuid>\r
     <RootNamespace>testsuite</RootNamespace>\r
@@ -41,6 +55,7 @@
     <ClCompile>\r
       <WarningLevel>Level3</WarningLevel>\r
       <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>NVALGRIND;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
     </ClCompile>\r
     <Link>\r
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
@@ -52,6 +67,7 @@
       <Optimization>MaxSpeed</Optimization>\r
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
       <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>NVALGRIND;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
     </ClCompile>\r
     <Link>\r
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
       <OptimizeReferences>true</OptimizeReferences>\r
     </Link>\r
   </ItemDefinitionGroup>\r
-  <ItemGroup>\r
-    <ClCompile Include="..\..\conout.c" />\r
-    <ClCompile Include="..\..\fs.c" />\r
-    <ClCompile Include="..\..\test.c" />\r
-    <ClCompile Include="..\..\util.c" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ClInclude Include="..\..\gmqcc.h" />\r
-  </ItemGroup>\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
   <ImportGroup Label="ExtensionTargets">\r
   </ImportGroup>\r
index 5cd16e30fda98c45e4e12c1a42fee98a2df513e4..fccab25f731d802b9be5ecbffa61b6267f5f9914 100755 (executable)
@@ -1,12 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>\r
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
   <ItemGroup>\r
-    <ClCompile Include="..\..\conout.c" />\r
     <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\opts.c" />\r
+    <ClCompile Include="..\..\stat.c" />\r
     <ClCompile Include="..\..\test.c" />\r
     <ClCompile Include="..\..\util.c" />\r
+    <ClCompile Include="..\..\conout.c" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="..\..\gmqcc.h" />\r
   </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="..\..\opts.def" />\r
+  </ItemGroup>\r
 </Project>
\ No newline at end of file
diff --git a/opts.c b/opts.c
index 98421a3177cee5789b70d599e29628394b8d3863..4f6660e5c1abc8c86d0629e15f181d6143719755 100644 (file)
--- a/opts.c
+++ b/opts.c
@@ -55,7 +55,7 @@ const opts_flag_def_t opts_flag_list[COUNT_FLAGS+1] = {
 };
 
 unsigned int opts_optimizationcount[COUNT_OPTIMIZATIONS];
-opts_cmd_t   opts; /* command lien options */
+opts_cmd_t   opts; /* command line options */
 
 static void opts_setdefault(void) {
     memset(&opts, 0, sizeof(opts_cmd_t));
index fbe725789c25d0358a88d3f04ca8c407d043ebeb..87b87264b123a4b13e87428f8d71b5f3525f5209 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -3866,7 +3866,7 @@ static bool parse_function_body(parser_t *parser, ast_value *var)
         self_think     = (ast_expression*)ast_entfield_new(ctx, gbl_self, fld_think);
 
         time_plus_1    = (ast_expression*)ast_binary_new(ctx, INSTR_ADD_F,
-                         gbl_time, (ast_expression*)fold_constgen_float(parser->fold, 0.1));
+                         gbl_time, (ast_expression*)fold_constgen_float(parser->fold, 0.1f));
 
         if (!self_frame || !self_nextthink || !self_think || !time_plus_1) {
             if (self_frame)     ast_delete(self_frame);
diff --git a/stat.c b/stat.c
index ffb5b227f26283b41add9cb27aefee081fa94c8c..7a2d195b6ba2e3a2d75daa6ed322076aad4f2836 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -412,7 +412,7 @@ GMQCC_INLINE size_t util_hthash(hash_table_t *ht, const char *key) {
     uint32_t k;
     uint32_t h = 0x1EF0 ^ len;
 
-    for (i = -block; i; i++) {
+    for (i = -((int)block); i; i++) {
         k  = blocks[i];
         k *= mask1;
         k  = GMQCC_ROTL32(k, 15);
diff --git a/test.c b/test.c
index d3132e25c342f807529630552c4480d406a11c47..e4873e0e83d79fa1d8d3f1b59add6aa6b7ba813e 100644 (file)
--- a/test.c
+++ b/test.c
@@ -162,8 +162,13 @@ static int task_pclose(FILE **handles) {
         char    *cmd  = NULL;
         popen_t *open = (popen_t*)mem_a(sizeof(popen_t));
 
+#ifndef _MSC_VER
         tmpnam(open->name_err);
         tmpnam(open->name_out);
+#else
+               tmpnam_s(open->name_err, L_tmpnam);
+               tmpnam_s(open->name_out, L_tmpnam);
+#endif
 
         (void)mode; /* excluded */
 
@@ -188,6 +193,8 @@ static int task_pclose(FILE **handles) {
 
         mem_d(open);
     }
+#      define popen _popen
+#      define pclose _pclose
 #endif /*! _WIN32 */
 
 #define TASK_COMPILE    0