Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Common - Base - Compiler (CLANG) - Configuration.h
    »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
    »Version«   4.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, Andrew Aye.  All Rights Reserved.
    This software is free for non-commercial use.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
    following conditions are met:
    Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
    Redistribution in binary form must reproduce this copyright notice, this list of conditions and the following disclaimers in the documentation and other materials
    provided with the distribution.
    The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
    The intellectual property rights of the algorithms used reside with Andrew Aye.
    You may not use this software, in whole or in part, in support of any commercial product without the express written consent of the author.
    There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
#if !defined(TGS_COMMON_BASE_COMPILER_CONFIGURATION_H)
#define TGS_COMMON_BASE_COMPILER_CONFIGURATION_H
#pragma once

#if !defined(TgCOMPILER_CLANG)
#error Build arguments do not indicate this compiler
#endif


/* == Common ============================================================================================================================================================ */

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Warnings and Messages                                                                                                                                                 */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

#if defined(TgCOMPILE_FORCE_ANSI)
#pragma clang diagnostic ignored "-Wunused-function"
#endif
#pragma clang diagnostic ignored "-Wcovered-switch-default" /* CLANG | LLVM optimizer should remove the default, and we use __assume(0) for MSVC */
#pragma clang diagnostic ignored "-W#pragma-messages" /* Build and Compiler (and Data, Time) are injected as part of the compile */
#pragma clang diagnostic ignored "-Wlanguage-extension-token" /* Triggers because of the use of intrinsics */
#pragma clang diagnostic ignored "-Wc++98-compat" /* Triggers because of static_assert */
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" /* Triggers because of variadic macros */
#pragma clang diagnostic ignored "-Wunused-local-typedef" /* Extra type definitions won't hurt anything - and they get created through the macros */
#pragma clang diagnostic ignored "-Wold-style-cast" /* use of old-style cast - triggers on CXX compilation */
#if defined(TGS_FINAL)
#pragma clang diagnostic ignored "-Wunused-parameter" /* use of old-style cast - triggers on CXX compilation */
#endif


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Macros                                                                                                                                                                */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

#define DIAG_STR(s) #s
#define DIAG_JOINSTR(x,y) DIAG_STR(x ## y)
#define DIAG_DO_PRAGMA(x) _Pragma (#x)
#define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x)

#define CLANG_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
#define CLANG_COMMAND(...) __VA_ARGS__
#define CLANG_PRAGMA(x) DIAG_DO_PRAGMA(clang x)

#define UNUSED_PARAM __attribute__((unused))
#define UNUSED_FUNC __attribute__((unused))
#define UNUSED_TYPE __attribute__((unused))

#define MSVC_ATTRIBUTE(...)
#define MSVC_PRAGMA(...)

#define MSVC_WARN_SUPPRESS(msvc_unused)
#define MSVC_WARN_DISABLE_PUSH(msvc_unused)
#define MSVC_WARN_DISABLE_POP(msvc_unused)

#define CLANG_WARN_SUPPRESS(clang_option) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,clang_option))
#define CLANG_WARN_DISABLE_PUSH(clang_option) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,clang_option))
#define CLANG_WARN_DISABLE_POP(...) DIAG_PRAGMA(pop)

#define WARN_SUPPRESS(msvc_unused,clang_option) CLANG_WARN_SUPPRESS(clang_option)
#define WARN_DISABLE_PUSH(msvc_unused,clang_option) CLANG_WARN_DISABLE_PUSH(clang_option)
#define WARN_DISABLE_POP(...) CLANG_WARN_DISABLE_POP()

#define TgANALYSIS_ASSUME(...)

#if defined(__cplusplus)
#define SWITCH_FALLTHROUGH CLANG_COMMAND([[clang::fallthrough]];)
#else
#define SWITCH_FALLTHROUGH 
#endif


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Keyword Replacements                                                                                                                                                  */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

#define DLL_IMPORT                          __attribute__((__dllimport__))/* Import function from DLL */
#define DLL_EXPORT                          __attribute__((__dllexport__)) /* Export function to DLL */
#define CDECL                               __attribute__((__cdecl__)) /* Standard C function */
#define STDCALL                             __attribute__((__stdcall__)) /* Standard calling convention */
#define TgTLS                               
#define TgALIAS                             __attribute__((__may_alias__))
#if __has_builtin(__builtin_expect)
    #define TgEXPECT_TRUE(...)                  __builtin_expect( (__VA_ARGS__), 1 )
    #define TgEXPECT_FALSE(...)                 __builtin_expect( (__VA_ARGS__), 0 )
#else
    #define TgEXPECT_TRUE(...)                  (__VA_ARGS__)
    #define TgEXPECT_FALSE(...)                 (__VA_ARGS__)
#endif
#define TgPASSINREG                         
#define TgALIGN(A)                          __attribute__((__aligned__(A)))

#if defined(TgCOMPILE_FORCE_ANSI)
    #define TgFORCEINLINE                       static __attribute__((__always_inline__)) /* Force code to be TgFORCEINLINE */
    #define TgINLINE                            static
#else
    #define TgFORCEINLINE                       static __inline __attribute__((__always_inline__)) /* Force code to be TgFORCEINLINE */
    #define TgINLINE                            static __inline
#endif

#if TgCOMPILE_ASSERT
    #define TgS_NO_DEFAULT(...)                 TgCRITICAL(0); __VA_ARGS__
#else
    #define TgS_NO_DEFAULT(...)                 __VA_ARGS__
#endif

#if __has_builtin(__builtin_trap)
    #define TgBREAK_INLINE                      __builtin_trap()
#else
    #define TgBREAK_INLINE                      abort()
#endif


/* ====================================================================================================================================================================== */
#endif