mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-11-03 23:36:12 -08:00 
			
		
		
		
	
		
			
				
	
	
		
			159 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			159 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#ifdef INTELLISENSE_DIRECTIVES
 | 
						|
#	pragma once
 | 
						|
#endif
 | 
						|
 | 
						|
#pragma region Platform Detection
 | 
						|
 | 
						|
/* Platform architecture */
 | 
						|
 | 
						|
#if defined( _WIN64 ) || defined( __x86_64__ ) || defined( _M_X64 ) || defined( __64BIT__ ) || defined( __powerpc64__ ) || defined( __ppc64__ ) || defined( __aarch64__ )
 | 
						|
#	ifndef GEN_ARCH_64_BIT
 | 
						|
#		define GEN_ARCH_64_BIT 1
 | 
						|
#	endif
 | 
						|
#else
 | 
						|
#	ifndef GEN_ARCH_32_BItxt_StrCaT
 | 
						|
#		define GEN_ARCH_32_BIT 1
 | 
						|
#	endif
 | 
						|
#endif
 | 
						|
 | 
						|
/* Platform OS */
 | 
						|
 | 
						|
#if defined( _WIN32 ) || defined( _WIN64 )
 | 
						|
#	ifndef GEN_SYSTEM_WINDOWS
 | 
						|
#		define GEN_SYSTEM_WINDOWS 1
 | 
						|
#	endif
 | 
						|
#elif defined( __APPLE__ ) && defined( __MACH__ )
 | 
						|
#	ifndef GEN_SYSTEM_OSX
 | 
						|
#		define GEN_SYSTEM_OSX 1
 | 
						|
#	endif
 | 
						|
#	ifndef GEN_SYSTEM_MACOS
 | 
						|
#		define GEN_SYSTEM_MACOS 1
 | 
						|
#	endif
 | 
						|
#elif defined( __unix__ )
 | 
						|
#	ifndef GEN_SYSTEM_UNIX
 | 
						|
#		define GEN_SYSTEM_UNIX 1
 | 
						|
#	endif
 | 
						|
#	if defined( ANDROID ) || defined( __ANDROID__ )
 | 
						|
#		ifndef GEN_SYSTEM_ANDROID
 | 
						|
#			define GEN_SYSTEM_ANDROID 1
 | 
						|
#		endif
 | 
						|
#		ifndef GEN_SYSTEM_LINUX
 | 
						|
#			define GEN_SYSTEM_LINUX 1
 | 
						|
#		endif
 | 
						|
#	elif defined( __linux__ )
 | 
						|
#		ifndef GEN_SYSTEM_LINUX
 | 
						|
#			define GEN_SYSTEM_LINUX 1
 | 
						|
#		endif
 | 
						|
#	elif defined( __FreeBSD__ ) || defined( __FreeBSD_kernel__ )
 | 
						|
#		ifndef GEN_SYSTEM_FREEBSD
 | 
						|
#			define GEN_SYSTEM_FREEBSD 1
 | 
						|
#		endif
 | 
						|
#	elif defined( __OpenBSD__ )
 | 
						|
#		ifndef GEN_SYSTEM_OPENBSD
 | 
						|
#			define GEN_SYSTEM_OPENBSD 1
 | 
						|
#		endif
 | 
						|
#	elif defined( __EMSCRIPTEN__ )
 | 
						|
#		ifndef GEN_SYSTEM_EMSCRIPTEN
 | 
						|
#			define GEN_SYSTEM_EMSCRIPTEN 1
 | 
						|
#		endif
 | 
						|
#	elif defined( __CYGWIN__ )
 | 
						|
#		ifndef GEN_SYSTEM_CYGWIN
 | 
						|
#			define GEN_SYSTEM_CYGWIN 1
 | 
						|
#		endif
 | 
						|
#	else
 | 
						|
#		error This UNIX operating system is not supported
 | 
						|
#	endif
 | 
						|
#else
 | 
						|
#	error This operating system is not supported
 | 
						|
#endif
 | 
						|
 | 
						|
/* Platform compiler */
 | 
						|
 | 
						|
#if defined( _MSC_VER )
 | 
						|
#	pragma message("Detected MSVC")
 | 
						|
// #	define GEN_COMPILER_CLANG 0
 | 
						|
#	define GEN_COMPILER_MSVC  1
 | 
						|
// #	define GEN_COMPILER_GCC   0
 | 
						|
#elif defined( __GNUC__ )
 | 
						|
#	pragma message("Detected GCC")
 | 
						|
// #	define GEN_COMPILER_CLANG 0
 | 
						|
// #	define GEN_COMPILER_MSVC  0
 | 
						|
#	define GEN_COMPILER_GCC   1
 | 
						|
#elif defined( __clang__ )
 | 
						|
#	pragma message("Detected CLANG")
 | 
						|
#	define GEN_COMPILER_CLANG 1
 | 
						|
// #	define GEN_COMPILER_MSVC  0
 | 
						|
// #	define GEN_COMPILER_GCC   0
 | 
						|
#else
 | 
						|
#	error Unknown compiler
 | 
						|
#endif
 | 
						|
 | 
						|
#if defined( __has_attribute )
 | 
						|
#	define GEN_HAS_ATTRIBUTE( attribute ) __has_attribute( attribute )
 | 
						|
#else
 | 
						|
#	define GEN_HAS_ATTRIBUTE( attribute ) ( 0 )
 | 
						|
#endif
 | 
						|
 | 
						|
#if defined(GEN_GCC_VERSION_CHECK)
 | 
						|
#  undef GEN_GCC_VERSION_CHECK
 | 
						|
#endif
 | 
						|
#if defined(GEN_GCC_VERSION)
 | 
						|
#  define GEN_GCC_VERSION_CHECK(major,minor,patch) (GEN_GCC_VERSION >= GEN_VERSION_ENCODE(major, minor, patch))
 | 
						|
#else
 | 
						|
#  define GEN_GCC_VERSION_CHECK(major,minor,patch) (0)
 | 
						|
#endif
 | 
						|
 | 
						|
#if !defined(GEN_COMPILER_C)
 | 
						|
#	ifdef __cplusplus
 | 
						|
#		define GEN_COMPILER_C   0
 | 
						|
#		define GEN_COMPILER_CPP 1
 | 
						|
#	else
 | 
						|
#		if defined(__STDC__)
 | 
						|
#			define GEN_COMPILER_C   1
 | 
						|
#		    define GEN_COMPILER_CPP 0
 | 
						|
#		else
 | 
						|
            // Fallback for very old C compilers
 | 
						|
#			define GEN_COMPILER_C   1
 | 
						|
#		    define GEN_COMPILER_CPP 0
 | 
						|
#		endif
 | 
						|
#   endif
 | 
						|
#endif
 | 
						|
 | 
						|
#if GEN_COMPILER_C
 | 
						|
#pragma message("GENCPP: Detected C")
 | 
						|
#endif
 | 
						|
 | 
						|
#pragma endregion Platform Detection
 | 
						|
 | 
						|
#pragma region Mandatory Includes
 | 
						|
 | 
						|
#	include <stdarg.h>
 | 
						|
#	include <stddef.h>
 | 
						|
 | 
						|
#	if defined( GEN_SYSTEM_WINDOWS )
 | 
						|
#		include <intrin.h>
 | 
						|
#	endif
 | 
						|
 | 
						|
#if GEN_COMPILER_C
 | 
						|
#include <assert.h>
 | 
						|
#include <stdbool.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#pragma endregion Mandatory Includes
 | 
						|
 | 
						|
#if GEN_DONT_USE_NAMESPACE || GEN_COMPILER_C
 | 
						|
#	if GEN_COMPILER_C
 | 
						|
#		define GEN_NS
 | 
						|
#		define GEN_NS_BEGIN
 | 
						|
#		define GEN_NS_END
 | 
						|
#	else
 | 
						|
#		define GEN_NS              ::
 | 
						|
#		define GEN_NS_BEGIN
 | 
						|
#		define GEN_NS_END
 | 
						|
#	endif
 | 
						|
#else
 | 
						|
#	define GEN_NS              gen::
 | 
						|
#	define GEN_NS_BEGIN        namespace gen {
 | 
						|
#	define GEN_NS_END          }
 | 
						|
#endif
 |