platform.h: removed Compiler Options
diff --git a/lib/common/mem.h b/lib/common/mem.h
index fb73ef0..32c63dd 100644
--- a/lib/common/mem.h
+++ b/lib/common/mem.h
@@ -46,8 +46,6 @@
 /*-**************************************************************
 *  Basic Types
 *****************************************************************/
-#ifndef BASIC_TYPES_DEFINED
-#define BASIC_TYPES_DEFINED
 #if  !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
 # include <stdint.h>
   typedef  uint8_t BYTE;
@@ -68,7 +66,6 @@
   typedef   signed long long  S64;
   typedef ptrdiff_t      iPtrDiff;
 #endif
-#endif
 
 
 /*-**************************************************************
diff --git a/programs/bench.c b/programs/bench.c
index 2b7436a..9b7f988 100644
--- a/programs/bench.c
+++ b/programs/bench.c
@@ -8,16 +8,27 @@
  */
 
 
+
+/* **************************************
+*  Compiler Warnings
+****************************************/
+#ifdef _MSC_VER
+#  define _CRT_SECURE_NO_WARNINGS                /* fopen */
+#  pragma warning(disable : 4127)                /* disable: C4127: conditional expression is constant */
+#endif
+
+
 /* *************************************
 *  Includes
 ***************************************/
-#include "platform.h"    /* Compiler options */
-#include "util.h"        /* UTIL_GetFileSize, UTIL_sleep */
+#include "platform.h"    /* Large Files support */
+#include "util.h"        /* UTIL_getFileSize, UTIL_sleep */
 #include <stdlib.h>      /* malloc, free */
 #include <string.h>      /* memset */
 #include <stdio.h>       /* fprintf, fopen, ftello64 */
 #include <time.h>        /* clock_t, clock, CLOCKS_PER_SEC */
 
+#include "mem.h"
 #define ZSTD_STATIC_LINKING_ONLY
 #include "zstd.h"
 #include "datagen.h"     /* RDG_genBuffer */
diff --git a/programs/datagen.c b/programs/datagen.c
index 8209c85..06b5ab9 100644
--- a/programs/datagen.c
+++ b/programs/datagen.c
@@ -9,14 +9,22 @@
 
 
 
+/* *************************************
+*  Compiler Options
+***************************************/
+#if defined(_MSC_VER)
+#  define _CRT_SECURE_NO_WARNINGS    /* removes Visual warning on strerror() */
+#  define _CRT_SECURE_NO_DEPRECATE   /* removes VS2005 warning on strerror() */
+#endif
+
 /*-************************************
 *  Dependencies
 **************************************/
-#include "platform.h"  /* Compiler options */
-#include "util.h"      /* U32 */
+#include "platform.h"  /* SET_BINARY_MODE */
 #include <stdlib.h>    /* malloc, free */
 #include <stdio.h>     /* FILE, fwrite, fprintf */
 #include <string.h>    /* memcpy */
+#include "mem.h"       /* U32 */
 
 
 /*-************************************
diff --git a/programs/dibio.c b/programs/dibio.c
index 1c22949..b99e717 100644
--- a/programs/dibio.c
+++ b/programs/dibio.c
@@ -9,17 +9,27 @@
 
 
 
+/* **************************************
+*  Compiler Warnings
+****************************************/
+#ifdef _MSC_VER
+#  define _CRT_SECURE_NO_WARNINGS                /* fopen */
+#  pragma warning(disable : 4127)                /* disable: C4127: conditional expression is constant */
+#endif
+
+
 /*-*************************************
 *  Includes
 ***************************************/
-#include "platform.h"       /* Compiler options */
-#include "util.h"           /* UTIL_GetFileSize, UTIL_getTotalFileSize */
+#include "platform.h"       /* Large Files support */
+#include "util.h"           /* UTIL_getFileSize, UTIL_getTotalFileSize */
 #include <stdlib.h>         /* malloc, free */
 #include <string.h>         /* memset */
 #include <stdio.h>          /* fprintf, fopen, ftello64 */
 #include <time.h>           /* clock_t, clock, CLOCKS_PER_SEC */
 #include <errno.h>          /* errno */
 
+#include "mem.h"            /* read */
 #include "error_private.h"
 #include "dibio.h"
 
diff --git a/programs/fileio.c b/programs/fileio.c
index fa52f9a..e2a90a6 100644
--- a/programs/fileio.c
+++ b/programs/fileio.c
@@ -11,21 +11,26 @@
 *  Compiler Options
 ***************************************/
 #ifdef _MSC_VER   /* Visual */
+#  define _CRT_SECURE_NO_WARNINGS  /* removes Visual warning on strerror() */
 #  pragma warning(disable : 4204)  /* non-constant aggregate initializer */
 #endif
+#if defined(__MINGW32__) && !defined(_POSIX_SOURCE)
+#  define _POSIX_SOURCE 1          /* disable %llu warnings with MinGW on Windows */
+#endif
 
 
 /*-*************************************
 *  Includes
 ***************************************/
-#include "platform.h"   /* Compiler options */
-#include "util.h"       /* UTIL_GetFileSize, _LARGEFILE64_SOURCE */
+#include "platform.h"   /* Large Files support, SET_BINARY_MODE */
+#include "util.h"       /* UTIL_getFileSize */
 #include <stdio.h>      /* fprintf, fopen, fread, _fileno, stdin, stdout */
 #include <stdlib.h>     /* malloc, free */
 #include <string.h>     /* strcmp, strlen */
 #include <time.h>       /* clock */
 #include <errno.h>      /* errno */
 
+#include "mem.h"
 #include "fileio.h"
 #define ZSTD_STATIC_LINKING_ONLY   /* ZSTD_magicNumber, ZSTD_frameHeaderSize_max */
 #include "zstd.h"
diff --git a/programs/platform.h b/programs/platform.h
index fe4bfde..0b82e46 100644
--- a/programs/platform.h
+++ b/programs/platform.h
@@ -26,25 +26,6 @@
 
 
 /* **************************************
-*  Compiler Options
-****************************************/
-#if defined(__INTEL_COMPILER)
-#  pragma warning(disable : 177)    /* disable: message #177: function was declared but never referenced */
-#endif
-#if defined(_MSC_VER)
-#  define _CRT_SECURE_NO_WARNINGS   /* Disable some Visual warning messages for fopen, strncpy */
-#  define _CRT_SECURE_NO_DEPRECATE  /* VS2005 */
-#  pragma warning(disable : 4127)   /* disable: C4127: conditional expression is constant */
-#  if (_MSC_VER <= 1800)            /* (1800 = Visual Studio 2013) */
-#    define snprintf sprintf_s      /* snprintf unsupported by Visual <= 2013 */
-#  endif
-#endif
-#if defined(__MINGW32__) && !defined(_POSIX_SOURCE)
-#  define _POSIX_C_SOURCE 1          /* enable __VA_ARGS__ and disable %llu warnings with MinGW on Windows */
-#endif
-
-
-/* **************************************
 *  Detect 64-bit OS
 *  http://nadeausoftware.com/articles/2012/02/c_c_tip_how_detect_processor_type_using_compiler_predefined_macros
 ****************************************/
@@ -110,6 +91,7 @@
 *  Detect if isatty() and fileno() are available
 ************************************************/
 #if (defined(__linux__) && (PLATFORM_POSIX_VERSION >= 1)) || (PLATFORM_POSIX_VERSION >= 200112L) || defined(__DJGPP__)
+#  include <unistd.h>   /* isatty */
 #  define IS_CONSOLE(stdStream) isatty(fileno(stdStream))
 #elif defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
 #  include <io.h>       /* _isatty */
diff --git a/programs/util.h b/programs/util.h
index 409f6d7..8b480b2 100644
--- a/programs/util.h
+++ b/programs/util.h
@@ -25,24 +25,35 @@
 #endif
 
 
+/* **************************************
+*  Compiler Options
+****************************************/
+#if defined(_MSC_VER)
+#  if (_MSC_VER <= 1800)            /* (1800 = Visual Studio 2013) */
+#    define snprintf sprintf_s      /* snprintf unsupported by Visual <= 2013 */
+#  endif
+#endif
+
+
 /*-****************************************
 *  Dependencies
 ******************************************/
-#include "platform.h"   /* Compiler options, PLATFORM_POSIX_VERSION */
-#include <stdlib.h>     /* malloc */
-#include <stddef.h>     /* size_t, ptrdiff_t */
-#include <stdio.h>      /* fprintf */
-#include <sys/types.h>  /* stat, utime */
-#include <sys/stat.h>   /* stat */
+#include "platform.h"     /* PLATFORM_POSIX_VERSION */
+#include <stdlib.h>       /* malloc */
+#include <stddef.h>       /* size_t, ptrdiff_t */
+#include <stdio.h>        /* fprintf */
+#include <sys/types.h>    /* stat, utime */
+#include <sys/stat.h>     /* stat */
 #if defined(_MSC_VER)
-#  include <sys/utime.h>   /* utime */
-#  include <io.h>          /* _chmod */
+#  include <sys/utime.h>  /* utime */
+#  include <io.h>         /* _chmod */
 #else
 #  include <unistd.h>     /* chown, stat */
 #  include <utime.h>      /* utime */
 #endif
-#include <time.h>       /* time */
+#include <time.h>         /* time */
 #include <errno.h>
+#include "mem.h"          /* U32, U64 */
 
 
 /*-****************************************
@@ -81,35 +92,12 @@
 #define LIST_SIZE_INCREASE   (8*1024)
 
 
-/*-**************************************************************
-*  Basic Types
-*****************************************************************/
-#ifndef BASIC_TYPES_DEFINED
-#define BASIC_TYPES_DEFINED
-#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
-# include <stdint.h>
-  typedef  uint8_t BYTE;
-  typedef uint16_t U16;
-  typedef  int16_t S16;
-  typedef uint32_t U32;
-  typedef  int32_t S32;
-  typedef uint64_t U64;
-  typedef  int64_t S64;
-#else
-  typedef unsigned char       BYTE;
-  typedef unsigned short      U16;
-  typedef   signed short      S16;
-  typedef unsigned int        U32;
-  typedef   signed int        S32;
-  typedef unsigned long long  U64;
-  typedef   signed long long  S64;
-#endif
-#endif
-
-
 /*-****************************************
 *  Compiler specifics
 ******************************************/
+#if defined(__INTEL_COMPILER)
+#  pragma warning(disable : 177)    /* disable: message #177: function was declared but never referenced, useful with UTIL_STATIC */
+#endif
 #if defined(__GNUC__)
 #  define UTIL_STATIC static __attribute__((unused))
 #elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
diff --git a/programs/zstdcli.c b/programs/zstdcli.c
index 29fcb74..978ffcf 100644
--- a/programs/zstdcli.c
+++ b/programs/zstdcli.c
@@ -23,7 +23,7 @@
 /*-************************************
 *  Dependencies
 **************************************/
-#include "platform.h" /* Compiler options, PLATFORM_POSIX_VERSION */
+#include "platform.h" /* IS_CONSOLE, PLATFORM_POSIX_VERSION */
 #include "util.h"     /* UTIL_HAS_CREATEFILELIST, UTIL_createFileList */
 #include <string.h>   /* strcmp, strlen */
 #include <errno.h>    /* errno */
diff --git a/tests/datagencli.c b/tests/datagencli.c
index c4bf489..2f3ebc4 100644
--- a/tests/datagencli.c
+++ b/tests/datagencli.c
@@ -11,8 +11,7 @@
 /*-************************************
 *  Dependencies
 **************************************/
-#include "platform.h"  /* Compiler options */
-#include "util.h"      /* U32 */
+#include "util.h"      /* Compiler options */
 #include <stdio.h>     /* fprintf, stderr */
 #include "datagen.h"   /* RDG_generate */
 
diff --git a/tests/fullbench.c b/tests/fullbench.c
index 439de5c..233b4e9 100644
--- a/tests/fullbench.c
+++ b/tests/fullbench.c
@@ -11,12 +11,12 @@
 /*_************************************
 *  Includes
 **************************************/
-#include "platform.h"    /* Compiler options */
-#include "util.h"        /* U32 */
+#include "util.h"        /* Compiler options, UTIL_GetFileSize */
 #include <stdlib.h>      /* malloc */
 #include <stdio.h>       /* fprintf, fopen, ftello64 */
 #include <time.h>        /* clock_t, clock, CLOCKS_PER_SEC */
 
+#include "mem.h"
 #ifndef ZSTD_DLL_IMPORT
     #include "zstd_internal.h"   /* ZSTD_blockHeaderSize, blockType_e, KB, MB */
     #define ZSTD_STATIC_LINKING_ONLY  /* ZSTD_compressBegin, ZSTD_compressContinue, etc. */
diff --git a/tests/fuzzer.c b/tests/fuzzer.c
index 9088e24..86d4c6b 100644
--- a/tests/fuzzer.c
+++ b/tests/fuzzer.c
@@ -12,6 +12,8 @@
 *  Compiler specific
 **************************************/
 #ifdef _MSC_VER    /* Visual Studio */
+#  define _CRT_SECURE_NO_WARNINGS     /* fgets */
+#  pragma warning(disable : 4127)     /* disable: C4127: conditional expression is constant */
 #  pragma warning(disable : 4204)     /* disable: C4204: non-constant aggregate initializer */
 #endif
 
@@ -19,8 +21,6 @@
 /*-************************************
 *  Includes
 **************************************/
-#include "platform.h"     /* Compiler options */
-#include "util.h"         /* U32 */
 #include <stdlib.h>       /* free */
 #include <stdio.h>        /* fgets, sscanf */
 #include <string.h>       /* strcmp */
@@ -30,6 +30,7 @@
 #include "zstd_errors.h"  /* ZSTD_getErrorCode */
 #include "zdict.h"        /* ZDICT_trainFromBuffer */
 #include "datagen.h"      /* RDG_genBuffer */
+#include "mem.h"
 #define XXH_STATIC_LINKING_ONLY
 #include "xxhash.h"       /* XXH64 */
 
diff --git a/tests/paramgrill.c b/tests/paramgrill.c
index 0825b37..5eabcba 100644
--- a/tests/paramgrill.c
+++ b/tests/paramgrill.c
@@ -11,15 +11,14 @@
 /*-************************************
 *  Dependencies
 **************************************/
-#include "platform.h"  /* Compiler options */
-#include "util.h"      /* UTIL_getFileSize */
+#include "util.h"      /* Compiler options, UTIL_GetFileSize */
 #include <stdlib.h>    /* malloc */
 #include <stdio.h>     /* fprintf, fopen, ftello64 */
 #include <string.h>    /* strcmp */
 #include <math.h>      /* log */
 #include <time.h>      /* clock_t */
 
-#include "mem.h"       /* MEM_32bits() */
+#include "mem.h"
 #define ZSTD_STATIC_LINKING_ONLY   /* ZSTD_parameters, ZSTD_estimateCCtxSize */
 #include "zstd.h"
 #include "datagen.h"
diff --git a/tests/zbufftest.c b/tests/zbufftest.c
index 87cf80b..14b7392 100644
--- a/tests/zbufftest.c
+++ b/tests/zbufftest.c
@@ -12,6 +12,8 @@
 *  Compiler specific
 **************************************/
 #ifdef _MSC_VER    /* Visual Studio */
+#  define _CRT_SECURE_NO_WARNINGS     /* fgets */
+#  pragma warning(disable : 4127)     /* disable: C4127: conditional expression is constant */
 #  pragma warning(disable : 4146)     /* disable: C4146: minus unsigned expression */
 #endif
 
@@ -19,12 +21,11 @@
 /*-************************************
 *  Includes
 **************************************/
-#include "platform.h"     /* Compiler options */
 #include <stdlib.h>       /* free */
 #include <stdio.h>        /* fgets, sscanf */
 #include <time.h>         /* clock_t, clock() */
 #include <string.h>       /* strcmp */
-#include "mem.h"          /* MEM_writeLE32 */
+#include "mem.h"
 #define ZSTD_STATIC_LINKING_ONLY   /* ZSTD_maxCLevel */
 #include "zstd.h"         /* ZSTD_compressBound */
 #define ZBUFF_STATIC_LINKING_ONLY  /* ZBUFF_createCCtx_advanced */
diff --git a/tests/zstreamtest.c b/tests/zstreamtest.c
index 9da0010..ce61930 100644
--- a/tests/zstreamtest.c
+++ b/tests/zstreamtest.c
@@ -12,6 +12,8 @@
 *  Compiler specific
 **************************************/
 #ifdef _MSC_VER    /* Visual Studio */
+#  define _CRT_SECURE_NO_WARNINGS     /* fgets */
+#  pragma warning(disable : 4127)     /* disable: C4127: conditional expression is constant */
 #  pragma warning(disable : 4146)     /* disable: C4146: minus unsigned expression */
 #endif
 
@@ -19,12 +21,11 @@
 /*-************************************
 *  Includes
 **************************************/
-#include "platform.h"     /* Compiler options */
 #include <stdlib.h>       /* free */
 #include <stdio.h>        /* fgets, sscanf */
 #include <time.h>         /* clock_t, clock() */
 #include <string.h>       /* strcmp */
-#include "mem.h"          /* MEM_writeLE32 */
+#include "mem.h"
 #define ZSTD_STATIC_LINKING_ONLY   /* ZSTD_maxCLevel, ZSTD_customMem */
 #include "zstd.h"         /* ZSTD_compressBound */
 #include "zstd_errors.h"  /* ZSTD_error_srcSize_wrong */
diff --git a/zlibWrapper/examples/zwrapbench.c b/zlibWrapper/examples/zwrapbench.c
index 8999657..e0aca00 100644
--- a/zlibWrapper/examples/zwrapbench.c
+++ b/zlibWrapper/examples/zwrapbench.c
@@ -11,14 +11,14 @@
 /* *************************************
 *  Includes
 ***************************************/
-#include "platform.h"    /* Compiler options */
-#include "util.h"        /* U32, UTIL_GetFileSize, UTIL_sleep */
+#include "util.h"        /* Compiler options, UTIL_GetFileSize, UTIL_sleep */
 #include <stdlib.h>      /* malloc, free */
 #include <string.h>      /* memset */
 #include <stdio.h>       /* fprintf, fopen, ftello64 */
 #include <time.h>        /* clock_t, clock, CLOCKS_PER_SEC */
 #include <ctype.h>       /* toupper */
 
+#include "mem.h"
 #define ZSTD_STATIC_LINKING_ONLY
 #include "zstd.h"
 #include "datagen.h"     /* RDG_genBuffer */