cxong / tinydir

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

_MSC_VER is the wrong macro to check for Windows support

seanmiddleditch opened this issue · comments

The _MSC_VER macro is used to detect Windows mode. This is the wrong macro to use. That macro detects which compiler is in use, not which platform is being targeted. Both GCC and Clang can create Windows application, as well as a number of other lesser known compilers. The correct macro to check for is _WIN32 which is enabled for any application which has the Win32 API available to it (even in 64-bit mode).

The current macro usage means that Windows support is only enabled specifically when using Microsoft's compiler.

Some compilers may make both Windows and POSIX APIs available, e.g. CygWin compiles. It may be useful to have a feature macro (like a TINYDIR_USE_WIN32 and TINYDIR_USE_POSIX or something) that explicitly forces tinydir to use one API or the other and to default to something sensible. Good defaults may well be to use the Win32 API if _WIN32 is defined and POSIX otherwise.

seanmiddleditch@f0254be fixes both this and #17 with merge conflicts already resolved.