Test for _WIN32 to check for building for Windows.
Test __MINGW32__ to check for using MinGW compiler (on Windows).
If _WIN32 is defined and __MINGW32__ is not defined, assume Microsoft compiler, headers and libraries.
There are other ways this could be done, testing _MSC_VER for example, but these tests work.
Tested with Visual Studio 2005, MinGW 4.6.1 on Windows (mingw-get-inst-
20110802.exe) and gcc 4.6.1
in Ubuntu 11.10 (Ubuntu/Linaro 4.6.1-9ubuntu3).
* This support based in part on work by Jon Griffiths.
*/
-#ifdef __MINGW32__
+#ifdef _WIN32 /* Windows platform, either MinGW or Visual Studio (MSVC) */
#include <windows.h>
#include <fcntl.h>
#define USE_WINCONSOLE
+#ifdef __MINGW32__
+#define HAVE_UNISTD_H
+#else
+/* Microsoft headers don't like old POSIX names */
+#define strdup _strdup
+#define snprintf _snprintf
+#endif
#else
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#define USE_TERMIOS
+#define HAVE_UNISTD_H
#endif
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
-#include <unistd.h>
#include "linenoise.h"
#include "utf8.h"