cxong / tinydir

Lightweight, portable and easy to integrate C directory and file reader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Force use of ANSI on Windows

opened this issue · comments

As I'm currently working on a project which needs to run under Windows and Linux simultaneously and I need to use ANSI coding, under MSVC 14 on Windows, I had problems to compile it, as everything was apparently targetted towards Unicode.

I changed line at 71 to
#if (defined _MSC_VER || defined __MINGW32__) && defined UNICODE

and added this after line 89

#if (defined _MSC_VER || defined __MINGW32__) && !defined UNICODE
#undef FindFirstFile
#define FindFirstFile FindFirstFileA
#undef FindNextFile
#define FindNextFile FindNextFileA
#define WIN32_FIND_DATA WIN32_FIND_DATAA
#define _tsplitpath_s _splitpath_s
#define _tsplitpath _splitpath
#endif

Don't know if there is a better workaround or if this is a good approach, just sharing :)

Modified the original post, as I realised now that I could have used UNICODE define (I definied new one, TINYANSI before and used that as a flag instead of built-in one...).

commented

If neither UNICODE nor _UNICODE are defined, then tinydir will use ANSI for everything. You can try it out with the example projects.

Does this work for you?

Yep.

Sorry for late reply, I forgot to change charset in project settings as I found out later from Unicode to MultiByte :(

Issue was in that so everything is OK now :)
(and was for some time :D :( )