diff --git a/Makefile.msvc b/Makefile.msvc index 99d2630..7bd90eb 100644 --- a/Makefile.msvc +++ b/Makefile.msvc @@ -3,7 +3,7 @@ CXXC = cl LINK=link CFLAGS = /O2 /GA /GL /Gy /Oi /Ob2 /nologo /W3 /EHsc /MT /wd4244 LDFLAGS = /link /OPT:REF /OPT:ICF /LTCG /NXCOMPAT /DYNAMICBASE ADVAPI32.LIB -DEFS = -D_CRT_SECURE_NO_DEPRECATE -DDLL_EXPORT \ +DEFS = -D_CRT_SECURE_NO_DEPRECATE -DCRFPP_DLL -DCRFPP_DLL_EXPORT -DDLL_EXPORT \ -DUNICODE -D_UNICODE \ -DHAVE_WINDOWS_H -DVERSION="\"0.59\"" -DPACKAGE="\"CRF++\"" INC = -I. -I.. diff --git a/common.h b/common.h index 4269227..a340d06 100644 --- a/common.h +++ b/common.h @@ -18,7 +18,9 @@ #include #if defined(_WIN32) && !defined(__CYGWIN__) -#define NOMINMAX +#ifndef NOMINMAX +# define NOMINMAX +#endif #include #endif @@ -180,7 +182,7 @@ std::wstring Utf8ToWide(const std::string &input); std::string WideToUtf8(const std::wstring &input); #endif -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__) #define WPATH(path) (CRFPP::Utf8ToWide(path).c_str()) #else #define WPATH(path) (path) @@ -210,10 +212,11 @@ class string_buffer: public std::string { string_buffer& operator<<(short int _n) { _ITOA(_n); } string_buffer& operator<<(int _n) { _ITOA(_n); } string_buffer& operator<<(long int _n) { _ITOA(_n); } + string_buffer& operator<<(long long _n) { _ITOA(_n); } string_buffer& operator<<(unsigned short int _n) { _UITOA(_n); } string_buffer& operator<<(unsigned int _n) { _UITOA(_n); } - // string_buffer& operator<<(unsigned long int _n) { _UITOA(_n); } - string_buffer& operator<<(size_t _n) { _UITOA(_n); } + string_buffer& operator<<(unsigned long int _n) { _UITOA(_n); } + string_buffer& operator<<(unsigned long long _n) { _UITOA(_n); } string_buffer& operator<<(char _n) { push_back(_n); return *this; diff --git a/crfpp.h b/crfpp.h index aa2dbda..f9b1aeb 100644 --- a/crfpp.h +++ b/crfpp.h @@ -20,12 +20,14 @@ extern "C" { #endif #ifdef _WIN32 -#include -# ifdef DLL_EXPORT -# define CRFPP_DLL_EXTERN __declspec(dllexport) -# define CRFPP_DLL_CLASS_EXTERN __declspec(dllexport) -# else -# define CRFPP_DLL_EXTERN __declspec(dllimport) +# include +# ifdef CRFPP_DLL +# ifdef CRFPP_DLL_EXPORT +# define CRFPP_DLL_EXTERN __declspec(dllexport) +# define CRFPP_DLL_CLASS_EXTERN __declspec(dllexport) +# else +# define CRFPP_DLL_EXTERN __declspec(dllimport) +# endif # endif #endif diff --git a/encoder.cpp b/encoder.cpp index 2c6f758..e2a0be2 100644 --- a/encoder.cpp +++ b/encoder.cpp @@ -10,7 +10,9 @@ #endif #if defined(_WIN32) && !defined(__CYGWIN__) -#define NOMINMAX +#ifndef NOMINMAX +# define NOMINMAX +#endif #include #endif diff --git a/mmap.h b/mmap.h index 22cb378..ebe3bcc 100644 --- a/mmap.h +++ b/mmap.h @@ -105,7 +105,8 @@ template class Mmap { CHECK_FALSE(false) << "unknown open mode:" << filename; } - hFile = ::CreateFileW(WPATH(filename), mode1, FILE_SHARE_READ, 0, + std::wstring wpath = Utf8ToWide(filename); + hFile = ::CreateFileW(wpath.c_str(), mode1, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); CHECK_FALSE(hFile != INVALID_HANDLE_VALUE) << "CreateFile() failed: " << filename;