Skip to content

Commit

Permalink
win32: fix ansi build
Browse files Browse the repository at this point in the history
  • Loading branch information
OV2 committed Jan 31, 2013
1 parent 58f28b2 commit c691b61
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions win32/CXML.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "CXML.h"
#include <windows.h>
#include <stdio.h>
#include "_tfwopen.h"
#ifndef UNICODE
#define _tFromTCHAR(x) CPToWide(x,CP_ACP)
Expand Down
3 changes: 2 additions & 1 deletion win32/_tfwopen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@



#ifdef UNICODE
#include <windows.h>
#include "_tfwopen.h"

Expand Down Expand Up @@ -204,6 +203,8 @@ WideToCP::WideToCP(const wchar_t *wideChars, unsigned int cp) {
WideCharToMultiByte(cp,0,wideChars,-1,cpchars,requiredChars,NULL,NULL);
}

#ifdef UNICODE

extern "C" FILE *_tfwopen(const char *filename, const char *mode ) {
wchar_t mode_w[30];
lstrcpyn(mode_w,Utf8ToWide(mode),29);
Expand Down
18 changes: 13 additions & 5 deletions win32/_tfwopen.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@
***********************************************************************************/



#ifdef UNICODE
#ifndef _TFWOPEN_H
#define _TFWOPEN_H

#ifdef UNICODE

#include <stdio.h>

#ifdef __cplusplus
Expand All @@ -194,8 +194,9 @@ int _twopen(const char *filename, int oflag, int pmode);
}
#endif

#endif // UNICODE

#ifdef __cplusplus
#include <fstream>

class Utf8ToWide {
private:
Expand Down Expand Up @@ -233,6 +234,12 @@ class WideToCP {
operator char *() { return cpchars; }
};

#endif // __cplusplus

#ifdef UNICODE
#ifdef __cplusplus
#include <fstream>

namespace std {
class u8nifstream: public std::ifstream
{
Expand Down Expand Up @@ -283,6 +290,7 @@ __forceinline static int remove(const char *filename) {
__forceinline static int open(const char *filename, int oflag, int pmode) {
return _twopen(filename, oflag, pmode);
}
#endif // _TFWOPEN_H

#endif
#endif // UNICODE

#endif // _TFWOPEN_H

0 comments on commit c691b61

Please sign in to comment.