#ifndef PREPROC_ENV_HEADER
#define PREPROC_ENV_HEADER

#ifndef _CRT_SECURE_NO_WARNINGS
    #define _CRT_SECURE_NO_WARNINGS
#endif

#if defined(__APPLE__) && defined(__MACH__)
    #define OS_MAC 1
#elif defined(_WIN32)
    #define OS_WINDOWS 1
#elif defined(__linux__)
    #define OS_POSIX 1
    #define OS_LINUX 1
#else
    #error Unsupported platform
#endif

#if defined(__clang__)
    #define COMPILER_CLANG 1
#elif defined(__GNUC__) || defined(__GNUG__)
    #define COMPILER_GCC 1
#elif defined(_MSC_VER)
    #define COMPILER_MSVC 1
#elif defined(__TINYC__)
    #define COMPILER_TCC 1
#else
    #error Unsupported compiler
#endif

#ifdef __cplusplus
    #define LANG_CPP 1
#else
    #define LANG_C 1
#endif

#ifndef OS_MAC
    #define OS_MAC 0
#endif

#ifndef OS_WINDOWS
    #define OS_WINDOWS 0
#endif

#ifndef OS_LINUX
    #define OS_LINUX 0
#endif

#ifndef OS_POSIX
    #define OS_POSIX 0
#endif

#ifndef COMPILER_MSVC
    #define COMPILER_MSVC 0
#endif

#ifndef COMPILER_CLANG
    #define COMPILER_CLANG 0
#endif

#ifndef COMPILER_GCC
    #define COMPILER_GCC 0
#endif

#ifndef COMPILER_TCC
    #define COMPILER_TCC 0
#endif

#ifndef LANG_CPP
    #define LANG_CPP 0
#endif

#ifndef LANG_C
    #define LANG_C 0
#endif

#if COMPILER_MSVC
    #define INLINE __forceinline
#elif COMPILER_GCC || COMPILER_CLANG
    #define INLINE __attribute__((always_inline)) inline
#else
    #define INLINE inline
#endif

#if COMPILER_GCC || COMPILER_CLANG
    #define FUNC_INTERNAL __attribute__((unused)) static
#else
    #define FUNC_INTERNAL static
#endif

#define FN FUNC_INTERNAL

#if defined(__cplusplus) && __cplusplus >= 201103L
    #define THREAD_LOCAL thread_local
#elif COMPILER_GCC || COMPILER_CLANG
    #define THREAD_LOCAL __thread
#elif COMPILER_MSVC
    #define THREAD_LOCAL __declspec(thread)
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
    #define THREAD_LOCAL _Thread_local
#elif COMPILER_TCC
    #define MA_THREAD_LOCAL _Thread_local
#else
    #error Couldnt figure out thread local, needs to be provided manually
#endif

#if COMPILER_CLANG
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wmicrosoft-enum-forward-reference"
#endif

#if LANG_CPP
    #define API extern "C"
#else
    #define API
#endif

#endif // PREPROC_ENV_HEADER