]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
gmqcc now builds on visual studio
authorDale Weiler <killfieldengine@gmail.com>
Tue, 14 Aug 2012 23:06:53 +0000 (19:06 -0400)
committerDale Weiler <killfieldengine@gmail.com>
Tue, 14 Aug 2012 23:06:53 +0000 (19:06 -0400)
gmqcc.h
gmqcc.vcxproj [new file with mode: 0755]
util.c

diff --git a/gmqcc.h b/gmqcc.h
index 8c097672351ffb4cffa5a127c5788f450059cec3..c0b5fb3ce4c3cfb46046bc5429f3fdc47070bae8 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
 #include <stdarg.h>
 #include <ctype.h>
 
+/*
+ * Disable some over protective warnings in visual studio because fixing them is a waste
+ * of my time.
+ */
+#ifdef _MSC_VER
+#      pragma warning(disable : 4244 ) // conversion from 'int' to 'float', possible loss of data
+#      pragma warning(disable : 4018 ) // signed/unsigned mismatch
+#      pragma warning(disable : 4996 ) // This function or variable may be unsafe
+#      pragma warning(disable : 4700 ) // uninitialized local variable used
+#endif
+
 #define GMQCC_VERSION_MAJOR 0
 #define GMQCC_VERSION_MINOR 1
 #define GMQCC_VERSION_PATCH 0
 #if   INT_MAX   == 0x7FFFFFFF
     typedef int            int32_t;
     typedef unsigned int   uint32_t;
-    typedef long           int64_t;
-    typedef unsigned long  uint64_t;
 #elif LONG_MAX  == 0x7FFFFFFF
     typedef long           int32_t;
     typedef unsigned long  uint32_t;
+#endif
 
+
+#if defined(__GNUC__) || defined (__CLANG__)
+       typedef int          int64_t  __attribute__((__mode__(__DI__)));
+       typedef unsigned int uint64_t __attribute__((__mode__(__DI__)));
+#elif defined(_MSC_VER)
+       typedef __int64          int64_t;
+       typedef unsigned __int64 uint64_t;
+#else
     /*
-     * It's nearly impossible to figure out a 64bit type at
-     * this point without making assumptions about the build
-     * enviroment.  So if clang or gcc is detected use some
-     * compiler builtins to create a 64 signed and unsigned
-     * type.
-     */
-#   if defined(__GNUC__) || defined (__CLANG__)
-        typedef int          int64_t  __attribute__((__mode__(__DI__)));
-        typedef unsigned int uint64_t __attribute__((__mode__(__DI__)));
-#   else
-        /*
-         * Incoorectly size the types so static assertions below will
-         * fail.  There is no valid way to get a 64bit type at this point
-         * without making assumptions of too many things.
-         */
-        typedef struct { char _fail : 0; } int64_t;
-        typedef struct { char _fail : 0; } uint64_t;
-#   endif
+    * Incoorectly size the types so static assertions below will
+    * fail.  There is no valid way to get a 64bit type at this point
+    * without making assumptions of too many things.
+    */
+    typedef struct { char _fail : 0; } int64_t;
+    typedef struct { char _fail : 0; } uint64_t;
 #endif
 #ifdef _LP64 /* long pointer == 64 */
     typedef unsigned long  uintptr_t;
@@ -175,7 +181,7 @@ typedef char uint32_size_is_correct [sizeof(uint32_t) == 4?1:-1];
 typedef char uint64_size_is_correct [sizeof(uint64_t) == 8?1:-1];
 typedef char int16_size_if_correct  [sizeof(int16_t)  == 2?1:-1];
 typedef char int32_size_is_correct  [sizeof(int32_t)  == 4?1:-1];
-typedef char int64_size_is_correct  [sizeof(int64_t)  == 8?1:-1];
+typedef char int64_size_is_correct  [sizeof(int64_t)  >= 8?1:-1];
 /* intptr_t / uintptr_t correct size check */
 typedef char uintptr_size_is_correct[sizeof(intptr_t) == sizeof(int*)?1:-1];
 typedef char intptr_size_is_correct [sizeof(uintptr_t)== sizeof(int*)?1:-1];
diff --git a/gmqcc.vcxproj b/gmqcc.vcxproj
new file mode 100755 (executable)
index 0000000..40111c9
--- /dev/null
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{85C266A8-7938-4AE6-AB64-428DC32B1ACD}</ProjectGuid>\r
+    <RootNamespace>gmqcc</RootNamespace>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <CharacterSet>NotSet</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>NotSet</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <OutDir>.\</OutDir>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <IntDir>.\</IntDir>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <TargetName>gmqcc</TargetName>\r
+    <GenerateManifest>false</GenerateManifest>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <OutDir>.</OutDir>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <IntDir>.</IntDir>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <TargetName>gmqcc</TargetName>\r
+    <GenerateManifest>false</GenerateManifest>\r
+  </PropertyGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <AdditionalIncludeDirectories>.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+      <ExceptionHandling>false</ExceptionHandling>\r
+      <BufferSecurityCheck>false</BufferSecurityCheck>\r
+      <FloatingPointModel>Fast</FloatingPointModel>\r
+      <PrecompiledHeaderFile>\r
+      </PrecompiledHeaderFile>\r
+      <PrecompiledHeaderOutputFile>\r
+      </PrecompiledHeaderOutputFile>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <ManifestFile>\r
+      </ManifestFile>\r
+      <ProgramDatabaseFile>$(TargetName).pdb</ProgramDatabaseFile>\r
+      <SubSystem>Console</SubSystem>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <AdditionalIncludeDirectories>.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+      <ExceptionHandling>false</ExceptionHandling>\r
+      <BufferSecurityCheck>false</BufferSecurityCheck>\r
+      <FloatingPointModel>Fast</FloatingPointModel>\r
+      <PrecompiledHeaderFile>\r
+      </PrecompiledHeaderFile>\r
+      <PrecompiledHeaderOutputFile>\r
+      </PrecompiledHeaderOutputFile>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <ManifestFile>\r
+      </ManifestFile>\r
+      <ProgramDatabaseFile>$(TargetName).pdb</ProgramDatabaseFile>\r
+      <SubSystem>Console</SubSystem>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="asm.c" />\r
+    <ClCompile Include="ast.c" />\r
+    <ClCompile Include="code.c" />\r
+    <ClCompile Include="error.c" />\r
+    <ClCompile Include="exec.c" />\r
+    <ClCompile Include="ir.c" />\r
+    <ClCompile Include="lexer.c" />\r
+    <ClCompile Include="main.c" />\r
+    <ClCompile Include="parser.c" />\r
+    <ClCompile Include="util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="ast.h" />\r
+    <ClInclude Include="execloop.h" />\r
+    <ClInclude Include="gmqcc.h" />\r
+    <ClInclude Include="ir.h" />\r
+    <ClInclude Include="lexer.h" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="flags.def" />\r
+    <None Include="warns.def" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/util.c b/util.c
index 51fafbde862c72ab84b34601746e8161351fd389..d105cfd5d631e0a1ed5ab328ad009a1f393ec6f6 100644 (file)
--- a/util.c
+++ b/util.c
@@ -37,7 +37,7 @@ struct memblock_t {
 
 void *util_memory_a(unsigned int byte, unsigned int line, const char *file) {
     struct memblock_t *info = malloc(sizeof(struct memblock_t) + byte);
-    void              *data =(void*)((uintptr_t)info+sizeof(struct memblock_t));
+    void              *data =(void*)((unsigned char*)info+sizeof(struct memblock_t));
     if (!data) return NULL;
     info->line = line;
     info->byte = byte;
@@ -54,7 +54,7 @@ void util_memory_d(void *ptrn, unsigned int line, const char *file) {
     void              *data = NULL;
     struct memblock_t *info = NULL;
     if (!ptrn) return;
-    data = (void*)((uintptr_t)ptrn-sizeof(struct memblock_t));
+    data = (void*)((unsigned char *)ptrn-sizeof(struct memblock_t));
     info = (struct memblock_t*)data;
 
     util_debug("MEM", "released:   % 8u (bytes) address 0x%08X @ %s:%u\n", info->byte, data, file, line);