/************************************************* // Copyright (C), 2017-2018, Sininm Game. // File name: macros_def.h // Author: sll // Version: 1.0 // Date: 2017/08/10 // Description: useful macro define // Others: // History: *************************************************/ #ifndef _MACROS_H_ #define _MACROS_H_ ////////////////////////////////////////////////////////////////////////// // platform #ifdef _WIN32 #pragma execution_character_set("utf-8") //中文使用utf8存储 #ifndef _PLATFORM_WINDOWS_ #define _PLATFORM_WINDOWS_ #endif // end of _PLATFORM_WINDOWS_ #ifdef _WIN64 #ifndef _PLATFORM_X64_ #define _PLATFORM_X64_ #endif // end of _PLATFORM_X64_ #else #ifndef _PLATFORM_X32_ #define _PLATFORM_X32_ #endif // end of _PLATFORM_X32_ #endif // _WIN64 #endif // _WIN32 #ifdef __linux__ #ifndef _PLATFORM_LINUX_ #define _PLATFORM_LINUX_ #endif // end of _PLATFORM_LINUX_ #ifdef __ANDROID__ #ifdef __ARM_32BIT_STATE #ifndef _PLATFORM_X32_ #define _PLATFORM_X32_ #endif #else #ifndef _PLATFORM_X64_ #define _PLATFORM_X64_ #endif // end of _PLATFORM_X64_ #endif #else #ifndef _PLATFORM_X64_ #define _PLATFORM_X64_ #endif // end of _PLATFORM_X64_ #endif #endif // __linux__ #ifdef __APPLE__ #ifndef _PLATFORM_APPLE_ #define _PLATFORM_APPLE_ #endif // end of _PLATFORM_APPLE_ #ifndef _PLATFORM_X64_ #define _PLATFORM_X64_ #endif // end of _PLATFORM_X64_ #endif // __APPLE__ ////////////////////////////////////////////////////////////////////////// // type define // Unsigned base types. typedef float len_t; #ifdef _PLATFORM_WINDOWS_ #ifndef NOMINMAX #define NOMINMAX #endif #include #include #pragma warning(disable: 4786) #pragma warning(disable: 4996) #pragma warning(disable: 4819) #ifndef PRId64 #define PRId64 "lld" #endif #ifndef DLL_EXPORT #define DLL_EXPORT __declspec(dllexport) #endif // end of DLL_EXPORT #endif // _PLATFORM_WINDOWS_ #if defined(_PLATFORM_LINUX_) || defined(_PLATFORM_APPLE_) #define _cdecl __attribute__((__cdecl__)) #include #include #include #ifndef stricmp #define stricmp strcasecmp #endif // end of stricmp #ifndef strnicmp #define strnicmp strncasecmp #endif // end of strnicmp #ifndef wcsicmp #define wcsicmp wcscasecmp #endif // end of wcsicmp #ifndef wcsnicmp #define wcsnicmp wcsncasecmp #endif // end of wcsnicmp #ifndef DLL_EXPORT #define DLL_EXPORT __attribute__((visibility("default"))) #endif // end of DLL_EXPORT #ifndef __cdecl #define __cdecl #endif // end of __cdecl #define MAX_PATH 260 #endif // _PLATFORM_LINUX_, _PLATFORM_APPLE_ ////////////////////////////////////////////////////////////////////////// // macro // release #ifndef SAFE_RELEASE #define SAFE_RELEASE(p) { if (p) { (p)->release(); (p) = NULL; } } #endif // end of SAFE_RELEASE // delete #ifndef SAFE_DELETE #define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } } #endif // end of SAFE_DELETE // delete array #ifndef SAFE_DELETE_ARRAY #define SAFE_DELETE_ARRAY(p) { if (p) { delete [] (p); (p) = NULL; } } #endif // end of SAFE_DELETE_ARRAY // open optimize(for function)(sample: #pragma OPTIMIZE_ON) #ifndef OPTIMIZE_ON #define OPTIMIZE_ON optimize("",on) #endif // end of OPTIMIZE_ON // close optimize((for function)(sample: #pragma OPTIMIZE_OFF) #ifndef OPTIMIZE_OFF #define OPTIMIZE_OFF optimize("",off) #endif // end of OPTIMIZE_OFF #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif #ifndef FORCE_INLINE #define FORCE_INLINE inline #endif #ifndef _INTERFACE #define _INTERFACE class #endif // end of _INTERFACE #if defined(_PLATFORM_WINDOWS_) #elif defined(_PLATFORM_LINUX_) // end of _PLATFORM_WINDOWS_ #include #endif // end of _PLATFORM_LINUX_ FORCE_INLINE void debug_point() { #if defined(_PLATFORM_WINDOWS_) // not implement #elif defined(_PLATFORM_LINUX_) // end of _PLATFORM_WINDOWS_ raise(SIGSTOP); #endif // end of _PLATFORM_LINUX_ } #ifndef STRING_FACTOR #define STRING_FACTOR 4 #endif #ifdef __GNUC__ // #define DEPRECATED __attribute__((deprecated)) #define DEPRECATED #elif defined(_MSC_VER) #define DEPRECATED __declspec(deprecated) #else #pragma message("WARNING: You need to implement DEPRECATED for this compiler") #define DEPRECATED #endif #endif // end of _MACROS_H_