Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mingw support #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.msvc
Original file line number Diff line number Diff line change
Expand Up @@ -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..
Expand Down
11 changes: 7 additions & 4 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#include <cmath>

#if defined(_WIN32) && !defined(__CYGWIN__)
#define NOMINMAX
#ifndef NOMINMAX
# define NOMINMAX
#endif
#include <windows.h>
#endif

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 8 additions & 6 deletions crfpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ extern "C" {
#endif

#ifdef _WIN32
#include <windows.h>
# ifdef DLL_EXPORT
# define CRFPP_DLL_EXTERN __declspec(dllexport)
# define CRFPP_DLL_CLASS_EXTERN __declspec(dllexport)
# else
# define CRFPP_DLL_EXTERN __declspec(dllimport)
# include <windows.h>
# 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

Expand Down
4 changes: 3 additions & 1 deletion encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#endif

#if defined(_WIN32) && !defined(__CYGWIN__)
#define NOMINMAX
#ifndef NOMINMAX
# define NOMINMAX
#endif
#include <windows.h>
#endif

Expand Down
3 changes: 2 additions & 1 deletion mmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ template <class T> 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;
Expand Down