diff --git a/.gitignore b/.gitignore index 76dc4a5c8..2241cd0aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /build +*.user* *~ *.swp diff --git a/CMakeLists.txt b/CMakeLists.txt index f9d34aa72..397d20da7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,11 @@ cmake_minimum_required(VERSION 2.6) project(mGBA C) set(BINARY_NAME mgba CACHE INTERNAL "Name of output binaries") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99") +if(NOT MSVC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99") +else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd4003 /wd4244 /wd4146") +endif() set(USE_CLI_DEBUGGER ON CACHE BOOL "Whether or not to enable the CLI-mode ARM debugger") set(USE_GDB_STUB ON CACHE BOOL "Whether or not to enable the GDB stub ARM debugger") set(USE_FFMPEG ON CACHE BOOL "Whether or not to enable FFmpeg support") @@ -187,7 +191,7 @@ if(APPLE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.6") endif() -if(NOT HAIKU) +if(NOT HAIKU AND NOT MSVC) list(APPEND OS_LIB m) endif() diff --git a/src/debugger/memory-debugger.c b/src/debugger/memory-debugger.c index 3043929ff..e4d880a5b 100644 --- a/src/debugger/memory-debugger.c +++ b/src/debugger/memory-debugger.c @@ -29,14 +29,14 @@ static uint32_t _popcount32(unsigned bits) { } \ } -#define CREATE_SHIM(NAME, RETURN, TYPES, ARGS...) \ +#define CREATE_SHIM(NAME, RETURN, TYPES, ...) \ static RETURN ARMDebuggerShim_ ## NAME TYPES { \ struct ARMDebugger* debugger; \ FIND_DEBUGGER(debugger, cpu); \ - return debugger->originalMemory.NAME(cpu, ARGS); \ + return debugger->originalMemory.NAME(cpu, __VA_ARGS__); \ } -#define CREATE_WATCHPOINT_SHIM(NAME, WIDTH, RETURN, TYPES, ARGS...) \ +#define CREATE_WATCHPOINT_SHIM(NAME, WIDTH, RETURN, TYPES, ...) \ static RETURN ARMDebuggerShim_ ## NAME TYPES { \ struct ARMDebugger* debugger; \ FIND_DEBUGGER(debugger, cpu); \ @@ -44,7 +44,7 @@ static uint32_t _popcount32(unsigned bits) { if (_checkWatchpoints(debugger, address, &info, WIDTH)) { \ ARMDebuggerEnter(debugger, DEBUGGER_ENTER_WATCHPOINT, &info); \ } \ - return debugger->originalMemory.NAME(cpu, ARGS); \ + return debugger->originalMemory.NAME(cpu, __VA_ARGS__); \ } #define CREATE_MULTIPLE_WATCHPOINT_SHIM(NAME) \ diff --git a/src/util/common.h b/src/util/common.h index bdf5af40c..4118b2241 100644 --- a/src/util/common.h +++ b/src/util/common.h @@ -22,12 +22,14 @@ #include "version.h" #ifdef _MSC_VER -typedef intptr_t off_t; +#include typedef intptr_t ssize_t; +#define inline __inline #define restrict __restrict #define strcasecmp _stricmp #define strncasecmp _strnicmp #define ftruncate _chsize +#define snprintf _snprintf #else #include #include diff --git a/src/util/string.h b/src/util/string.h index c49bc06d0..12f088741 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -8,12 +8,12 @@ #include "util/common.h" -#ifndef strndup +#ifndef HAVE_STRNDUP // This is sometimes a macro char* strndup(const char* start, size_t len); #endif -#ifndef strdup +#ifndef HAVE_STRDUP char* strdup(const char* str); #endif