Created
November 16, 2022 05:24
-
-
Save atcarter714/34088b587585fea057f7d744e1d95813 to your computer and use it in GitHub Desktop.
Modified version of "sparseconfig.h" to fix IL2CPP build failures in Unity-generated UWP solutions for building your game for UWP (i.e., Windows Store, XBox Store, etc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* NOTE: This file is for internal use only. | |
* Do not use these #defines in your own program! | |
*/ | |
/* MODIFIED FILE: -------------------------------------------------------------------------------------- | |
* Since Unity 2022.2b versions fail when trying to build your project for Windows, UWP, etc, this file | |
* must be modified with a special preprocessor directive so that IL2CPP doesn't use the incorrect headers | |
* and freak out on you. I defined it just above the place where it defines the SPARSEHASH_HASH and the | |
* SPARSEHASH_HASH_NO_NAMESPACE symbols. I have only tested this on Windows in Visual Studio, but there are | |
* other preprocessor blocks like the one below the main one that says "POSIX build platforms" ... if by some | |
* chance you are compiling on a different system and with different compiler, you may need to redefine or | |
* move the directive into the appropriate block so it's not ignored by your preprocessor. In any case, you | |
* just need this to be picked up by the preprocessor: | |
* | |
* #define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS | |
* | |
* That directive should rescue you from your hell. A C#-based workaround is possible if building inside of | |
* Unity itself, which can be found here: https://gist.github.com/atcarter714/6e3d93a86ae6d1f3c0606040e917ea27 | |
* By simply putting that in a .cs code file anywhere in your Assets folder it also solves the problem ... | |
* -------------------------------------------------------------------------------------------------------- */ | |
/* Namespace for Google classes */ | |
#define GOOGLE_NAMESPACE ::google | |
/* Stops putting the code inside the Google namespace */ | |
#define _END_GOOGLE_NAMESPACE_ } | |
/* Puts following code inside the Google namespace */ | |
#define _START_GOOGLE_NAMESPACE_ namespace google { | |
/***************************/ | |
/* Windows build platforms */ | |
/***************************/ | |
#if defined(_MSC_VER) | |
#if (_MSC_VER >= 1800 ) | |
/* the location of the header defining hash functions */ | |
#define HASH_FUN_H <unordered_map> | |
#else /* Earlier than VSC++ 2013 */ | |
/* the location of the header defining hash functions */ | |
#define HASH_FUN_H <hash_map> | |
#endif | |
/* the namespace of the hash<> function */ | |
#define HASH_NAMESPACE stdext | |
/* Define to 1 if you have the <inttypes.h> header file. */ | |
#undef HAVE_INTTYPES_H | |
/* Define to 1 if the system has the type `long long'. */ | |
#define HAVE_LONG_LONG 1 | |
/* Define to 1 if you have the `memcpy' function. */ | |
#define HAVE_MEMCPY 1 | |
/* Define to 1 if you have the <stdint.h> header file. */ | |
#undef HAVE_STDINT_H | |
/* Define to 1 if you have the <sys/types.h> header file. */ | |
#define HAVE_SYS_TYPES_H 1 | |
/* Define to 1 if the system has the type `uint16_t'. */ | |
#undef HAVE_UINT16_T | |
/* Define to 1 if the system has the type `u_int16_t'. */ | |
#undef HAVE_U_INT16_T | |
/* Define to 1 if the system has the type `__uint16'. */ | |
#define HAVE___UINT16 1 | |
// -------------------------------------------------------------------------------------------------- | |
//! Add this preprocessor directive for IL2CPP: | |
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS | |
// -------------------------------------------------------------------------------------------------- | |
/* The system-provided hash function including the namespace. */ | |
#define SPARSEHASH_HASH HASH_NAMESPACE::hash_compare | |
/* The system-provided hash function, in namespace HASH_NAMESPACE. */ | |
#define SPARSEHASH_HASH_NO_NAMESPACE hash_compare | |
/*************************/ | |
/* POSIX build platforms */ | |
/*************************/ | |
#else | |
/* the location of the header defining hash functions */ | |
#define HASH_FUN_H <functional> | |
/* the namespace of the hash<> function */ | |
#define HASH_NAMESPACE std | |
/* Define to 1 if you have the <inttypes.h> header file. */ | |
#define HAVE_INTTYPES_H 1 | |
/* Define to 1 if the system has the type `long long'. */ | |
#define HAVE_LONG_LONG 1 | |
/* Define to 1 if you have the `memcpy' function. */ | |
#define HAVE_MEMCPY 1 | |
/* Define to 1 if you have the <stdint.h> header file. */ | |
#define HAVE_STDINT_H 1 | |
/* Define to 1 if you have the <sys/types.h> header file. */ | |
#define HAVE_SYS_TYPES_H 1 | |
/* Define to 1 if the system has the type `uint16_t'. */ | |
#define HAVE_UINT16_T 1 | |
/* Define to 1 if the system has the type `u_int16_t'. */ | |
#define HAVE_U_INT16_T 1 | |
/* Define to 1 if the system has the type `__uint16'. */ | |
/* #undef HAVE___UINT16 */ | |
/* The system-provided hash function including the namespace. */ | |
#define SPARSEHASH_HASH HASH_NAMESPACE::hash | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hope this helps solve any IL2CPP build woes folks have experienced with cutting-edge Unity versions like 2022.2.XX betas.