Some fixes for MSVC.

This commit is contained in:
Su Yong 2017-02-11 10:57:35 +08:00
parent 8754a8f6d8
commit 4e096c127c
15 changed files with 84 additions and 24 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
@ -397,6 +401,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 +420,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)
@ -613,6 +625,12 @@ IF( ENABLE_FFMPEG )
)
ENDIF( ENABLE_FFMPEG )
if(MSVC)
INCLUDE_DIRECTORIES(
dependencies/msvc # for getopt.h
)
endif()
ADD_LIBRARY (
vbamcore
STATIC

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,11 @@
#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
IF(CMAKE_COMPILER_IS_GNUCXX)
SET( CMAKE_CXX_FLAGS -std=gnu++11 )
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
# not yet implemented
SET(CAIRO_DEFAULT OFF)
@ -144,6 +149,10 @@ ENDIF(WIN32 AND ENABLE_DIRECTX)
# contrib widgets
include_directories(widgets)
IF(MSVC)
include_directories(../../dependencies/msvc) # for GL/glext.h
ENDIF(MSVC)
# for out-of-tree builds, grab includes from both target and source dirs
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
@ -301,10 +310,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

@ -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;