Merge pull request #70 from edorax/master

Some fixes for MSVC.
This commit is contained in:
Rafael Kitover 2017-02-11 08:02:02 -08:00 committed by GitHub
commit 98718f2094
18 changed files with 98 additions and 34 deletions

View File

@ -64,6 +64,10 @@ ENDIF()
OPTION(ENABLE_LTO "Compile with Link Time Optimization (gcc and clang only)" ${LTO_DEFAULT})
if(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
endif(MSVC)
option( ENABLE_GBA_LOGGING "Enable extended GBA logging" ON )
if( ENABLE_GBA_LOGGING )
ADD_DEFINITIONS (-DGBA_LOGGING )
@ -191,8 +195,8 @@ IF( NOT SYSCONF_INSTALL_DIR )
ENDIF( NOT SYSCONF_INSTALL_DIR )
# C defines
ADD_DEFINITIONS (-DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DHAVE_ZLIB_H -DFINAL_VERSION -DSDL -DUSE_OPENGL -DSYSCONF_INSTALL_DIR='"${SYSCONF_INSTALL_DIR}"' -DWITH_LIRC='${WITHLIRC}')
ADD_DEFINITIONS (-DVERSION='"${VERSION}"' -DPKGDATADIR='"${PKGDATADIR}"' -DPACKAGE='')
ADD_DEFINITIONS (-DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DHAVE_ZLIB_H -DFINAL_VERSION -DSDL -DUSE_OPENGL -DSYSCONF_INSTALL_DIR=\\\""${SYSCONF_INSTALL_DIR}"\\\" -DWITH_LIRC=${WITHLIRC})
ADD_DEFINITIONS (-DVERSION=\\\""${VERSION}"\\\" -DPKGDATADIR=\\\""${PKGDATADIR}"\\\" -DPACKAGE=)
if( ENABLE_LINK )
# IPC linking code needs sem_timedwait which can be either in librt or pthreads
@ -233,7 +237,7 @@ ENDIF( NOT ENABLE_ASM_CORE )
if( ENABLE_NLS )
SET( LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale )
ADD_DEFINITIONS ( -DENABLE_NLS )
ADD_DEFINITIONS ( -DLOCALEDIR='"${LOCALEDIR}"' )
ADD_DEFINITIONS ( -DLOCALEDIR=\\\""${LOCALEDIR}"\\\" )
# for now, only GBALink.cpp uses gettext() directly
IF(APPLE)
# use Homebrew gettext if available
@ -271,6 +275,11 @@ IF(WIN32)
ENDIF()
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
IF(MSVC)
SET(DEPS_MSVC "${CMAKE_SOURCE_DIR}/dependencies/msvc")
INCLUDE_DIRECTORIES("${DEPS_MSVC}") # for GL/glext.h and getopt.h
ENDIF()
ENDIF()
# Compiler flags
@ -317,10 +326,6 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
ENDIF()
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(MY_C_FLAGS ${MY_C_FLAGS} -std=gnu++11)
ENDIF()
IF(MINGW)
SET(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++)
ENDIF(MINGW)
@ -335,6 +340,11 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
ADD_COMPILE_OPTIONS(${C_COMPILE_FLAG})
ENDFOREACH()
# This one must be set for C++ only, and we can't use generator expressions
# in ADD_COMPILE_OPTIONS because that's a cmake 3.3 feature and we need
# 2.8.12 compat for Ubuntu 14.
SET(CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT} -std=gnu++11")
# make a string of compile options to add to link flags
UNSET(C_COMPILE_FLAGS_STR)
@ -397,6 +407,10 @@ SET(SRC_MAIN
src/common/SoundSDL.cpp
)
if(MSVC)
SET(SRC_MAIN ${SRC_MAIN} "dependencies/msvc/getopt.c")
endif(MSVC)
SET(HDR_MAIN
src/AutoBuild.h
src/System.h
@ -412,6 +426,10 @@ SET(HDR_MAIN
src/common/SoundSDL.h
)
if(MSVC)
SET(HDR_MAIN ${HDR_MAIN} "dependencies/msvc/getopt.h")
endif(MSVC)
if(ENABLE_FFMPEG)
SET(SRC_MAIN ${SRC_MAIN} src/common/ffmpeg.cpp)
SET(HDR_MAIN ${HDR_MAIN} src/common/ffmpeg.h)

View File

@ -89,7 +89,8 @@ SET(SDL2_SEARCH_PATHS
/opt/local # MacPorts
/opt/csw # OpenCSW (Solaris)
/opt
${SDL2_PATH}
${SDL2_PATH}/include
${SDL2_PATH}/lib
)
FIND_PATH(SDL2_INCLUDE_DIR SDL.h

View File

@ -34,6 +34,7 @@ SET(SRC_FEX
INCLUDE_DIRECTORIES(
.
${ZLIB_INCLUDE_DIRS}
)
ADD_LIBRARY(

View File

@ -820,6 +820,28 @@ const char* ReadPrefString(const char* pref_key)
return ReadPrefString(pref_key, "");
}
/*-------------------------------------------------------------------------*/
/**
@brief Duplicate a string
@param s String to duplicate
@return Pointer to a newly allocated string, to be freed with free()
This is a replacement for strdup(). This implementation is provided
for systems that do not have it.
*/
/*--------------------------------------------------------------------------*/
static char *xstrdup(const char *s)
{
char *t;
if (!s)
return NULL;
t = (char *)malloc(strlen(s) + 1);
if (t) {
strcpy(t, s);
}
return t;
}
int ReadOpts(int argc, char ** argv)
{
int op = -1;
@ -859,7 +881,7 @@ int ReadOpts(int argc, char ** argv)
log("Missing BIOS file name\n");
break;
}
biosFileNameGBA = strdup(optarg);
biosFileNameGBA = xstrdup(optarg);
break;
case 'c':
{

View File

@ -18,6 +18,8 @@
#ifndef __VBA_SOUND_DRIVER_H__
#define __VBA_SOUND_DRIVER_H__
#include <stdint.h> // for uint16_t
/**
* Sound driver abstract interface for the core to use to output sound.
* Subclass this to implement a new sound driver.

View File

@ -717,8 +717,9 @@ int ZEXPORT memgzclose(file) gzFile file;
long ZEXPORT memtell(file) gzFile file;
{
mem_stream *s;
do_flush(file, Z_FULL_FLUSH); // makes memtell to tell truth
mem_stream *s = (mem_stream *)file;
s = (mem_stream *)file;
if (s == NULL)
return Z_STREAM_ERROR;

View File

@ -1,6 +1,7 @@
#Do not use this file directly. Always use the top level CMakeLists.txt file
# This build is much easier if we just do it here.
SET( CMAKE_CXX_FLAGS -std=gnu++11 )
cmake_policy(SET CMP0043 NEW) # for wxWidgets
# not yet implemented
SET(CAIRO_DEFAULT OFF)
@ -198,9 +199,16 @@ IF(CMAKE_HOST_WIN32)
SET(BIN2C ${BIN2C}.exe)
ENDIF()
ADD_CUSTOM_COMMAND(OUTPUT ${BIN2C}
COMMAND cc ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c -o ${BIN2C}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c)
IF(MSVC)
ADD_CUSTOM_COMMAND(OUTPUT ${BIN2C}
COMMAND cl ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c /link "/out:${BIN2C}"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c)
ELSE(MSVC)
ADD_CUSTOM_COMMAND(OUTPUT ${BIN2C}
COMMAND cc ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c -o ${BIN2C}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c)
ENDIF(MSVC)
ADD_CUSTOM_COMMAND(OUTPUT wxvbam.xrs
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND wxrc ${XRC_SOURCES} -o wxvbam.xrs
@ -301,10 +309,14 @@ ENDIF(ENABLE_XAUDIO2)
IF( WIN32 )
SET( SRC_WX ${SRC_WX} wxvbam.rc dsound.cpp )
SET(DIRECTX_LIBRARIES -ldxguid -ldsound -lws2_32)
SET(DIRECTX_LIBRARIES dxguid dsound ws2_32)
IF(MSVC)
# workaround for some symbols needed by static SDL2.lib
SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} imm32 version)
ENDIF(MSVC)
# not strictly directx, but win32-related
IF(ENABLE_DEBUGGER)
SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} -lwsock32)
SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} wsock32)
ENDIF(ENABLE_DEBUGGER)
ENDIF( WIN32 )

View File

@ -34,7 +34,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ctype.h>
#include <wchar.h>
#include <locale.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include <wctype.h>
#define BUF_SIZE 4096

View File

@ -192,7 +192,8 @@ bool DirectSound::init(long sampleRate)
void DirectSound::pause()
{
for (auto buf : {dsbPrimary, dsbSecondary}) {
LPDIRECTSOUNDBUFFER bufs[] = {dsbPrimary, dsbSecondary};
for (auto buf : bufs) {
if (buf == NULL)
continue;
@ -216,7 +217,8 @@ void DirectSound::reset()
void DirectSound::resume()
{
for (auto buf : {dsbPrimary, dsbSecondary}) {
LPDIRECTSOUNDBUFFER bufs[] = {dsbPrimary, dsbSecondary};
for (auto buf : bufs) {
if (buf == NULL)
return;

View File

@ -752,7 +752,7 @@ public:
int count8, count16, count32; // number of aligned addresses in addrs
wxString OnGetItemText(long item, long column) const;
DECLARE_DYNAMIC_CLASS()
DECLARE_DYNAMIC_CLASS(CheatListCtrl)
};
IMPLEMENT_DYNAMIC_CLASS(CheatListCtrl, wxListCtrl);

View File

@ -1308,6 +1308,7 @@ DrawingPanelBase::DrawingPanelBase(int _width, int _height)
: width(_width)
, height(_height)
, scale(1)
, did_init(false)
, todraw(0)
, pixbuf1(0)
, pixbuf2(0)

View File

@ -686,7 +686,7 @@ private:
wxRect margins;
int npw, nph;
DECLARE_CLASS()
DECLARE_CLASS(PrintDialog)
};
IMPLEMENT_CLASS(PrintDialog, wxEvtHandler)

View File

@ -14,6 +14,8 @@
#include <wx/stattext.h>
#include <wx/checkbox.h>
#include <stdint.h> // for uint32_t
// avoid exporting too much stuff
namespace Viewers {
// common to all viewers:
@ -151,7 +153,7 @@ protected:
uint32_t seladdr;
bool issel;
DECLARE_DYNAMIC_CLASS() // for xrc
DECLARE_DYNAMIC_CLASS(DisList) // for xrc
DECLARE_EVENT_TABLE()
};
@ -229,7 +231,7 @@ protected:
bool isasc;
void ShowCaret();
DECLARE_DYNAMIC_CLASS() // for xrc
DECLARE_DYNAMIC_CLASS(MemView) // for xrc
DECLARE_EVENT_TABLE()
};
@ -314,7 +316,7 @@ protected:
int ox, oy, selx, sely;
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS()
DECLARE_DYNAMIC_CLASS(PixView)
};
#define pixview(v, n, w, h, cv) \
do { \
@ -348,7 +350,7 @@ protected:
private:
int selx, sely;
DECLARE_DYNAMIC_CLASS()
DECLARE_DYNAMIC_CLASS(GfxPanel)
DECLARE_EVENT_TABLE()
};
@ -398,7 +400,7 @@ protected:
// always generates a GFX_CLICK
void SelPoint(wxMouseEvent& ev);
void click();
DECLARE_DYNAMIC_CLASS()
DECLARE_DYNAMIC_CLASS(PixViewEvt)
};
// a display-only checkbox which does not look like it's disabled
@ -412,7 +414,7 @@ public:
{
}
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS()
DECLARE_DYNAMIC_CLASS(DispCheckBox)
};
// standard widgets in graphical viewers

View File

@ -62,7 +62,7 @@ public:
protected:
void OnJoy(wxSDLJoyEvent&);
DECLARE_DYNAMIC_CLASS();
DECLARE_DYNAMIC_CLASS(wxJoyKeyTextCtrl);
DECLARE_EVENT_TABLE();
};

View File

@ -74,7 +74,7 @@ protected:
// the last keydown event received; this is processed on next keyup
int lastmod, lastkey;
DECLARE_DYNAMIC_CLASS();
DECLARE_DYNAMIC_CLASS(wxKeyTextCtrl);
DECLARE_EVENT_TABLE();
};

View File

@ -23,7 +23,7 @@ protected:
void UpdatedValue();
void UpdateEvt(wxCommandEvent& ev);
wxFarRadio* Next;
DECLARE_DYNAMIC_CLASS()
DECLARE_DYNAMIC_CLASS(wxFarRadio)
DECLARE_EVENT_TABLE()
};

View File

@ -5,7 +5,6 @@
// create & display main frame
#include "wxvbam.h"
#include <unistd.h>
#include <stdio.h>
#include <wx/cmdline.h>
#include <wx/file.h>

View File

@ -307,7 +307,7 @@ public:
virtual bool DialogOpened() { return dialog_opened != 0; }
// required for building from xrc
DECLARE_DYNAMIC_CLASS();
DECLARE_DYNAMIC_CLASS(MainFrame);
// required for event handling
DECLARE_EVENT_TABLE();
@ -364,12 +364,13 @@ private:
// helper class to add HiDPI awareness (mostly for Mac OS X)
class HiDPIAware {
public:
HiDPIAware() { hidpi_scale_factor = 0; }
virtual double HiDPIScaleFactor();
virtual void RequestHighResolutionOpenGLSurface();
virtual void GetRealPixelClientSize(int* x, int* y);
virtual wxWindow* GetWindow() = 0;
private:
double hidpi_scale_factor = 0;
double hidpi_scale_factor;
};
// a helper class to avoid forgetting StopModal()
@ -624,7 +625,7 @@ protected:
bool pointer_blanked;
uint32_t mouse_active_time;
DECLARE_DYNAMIC_CLASS()
DECLARE_DYNAMIC_CLASS(GameArea)
DECLARE_EVENT_TABLE()
};
@ -667,7 +668,7 @@ protected:
int width, height;
double scale;
virtual void DrawingPanelInit();
bool did_init = false;
bool did_init;
uint8_t* todraw;
uint8_t *pixbuf1, *pixbuf2;
FilterThread* threads;