From: Dale Weiler Date: Tue, 14 Aug 2012 23:06:53 +0000 (-0400) Subject: gmqcc now builds on visual studio X-Git-Tag: 0.1-rc1~277^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d73100ad1b72ac779b5aa949aab7d17ec6a1555d;p=xonotic%2Fgmqcc.git gmqcc now builds on visual studio --- diff --git a/gmqcc.h b/gmqcc.h index 8c09767..c0b5fb3 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -29,6 +29,17 @@ #include #include +/* + * 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 @@ -135,31 +146,26 @@ #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 index 0000000..40111c9 --- /dev/null +++ b/gmqcc.vcxproj @@ -0,0 +1,131 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {85C266A8-7938-4AE6-AB64-428DC32B1ACD} + gmqcc + + + + Application + true + NotSet + + + Application + false + true + NotSet + + + + + + + + + + + + + .\ + + + .\ + + + gmqcc + false + + + . + + + . + + + gmqcc + false + + + + Level3 + Disabled + .\;%(AdditionalIncludeDirectories) + false + false + Fast + + + + + + + true + + + $(TargetName).pdb + Console + + + + + Level3 + MaxSpeed + true + true + .\;%(AdditionalIncludeDirectories) + false + false + Fast + + + + + + + true + true + true + + + $(TargetName).pdb + Console + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/util.c b/util.c index 51fafbd..d105cfd 100644 --- 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);