MdePkg: Add STATIC_ASSERT macro
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2048 Provide a macro for compile time assertions. Equivalent to C11 static_assert macro from assert.h. Signed-off-by: Vitaly Cheptsov <vit9696@protonmail.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Acked-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
		
				
					committed by
					
						 Liming Gao
						Liming Gao
					
				
			
			
				
	
			
			
			
						parent
						
							5e5abfcab4
						
					
				
				
					commit
					204ae9da23
				
			| @@ -843,6 +843,20 @@ typedef UINTN  *BASE_LIST; | |||||||
| #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field)) | #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field)) | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   Portable definition for compile time assertions. | ||||||
|  |   Equivalent to C11 static_assert macro from assert.h. | ||||||
|  |  | ||||||
|  |   @param  Expression  Boolean expression. | ||||||
|  |   @param  Message     Raised compiler diagnostic message when expression is false. | ||||||
|  |  | ||||||
|  | **/ | ||||||
|  | #ifdef _MSC_EXTENSIONS | ||||||
|  |   #define STATIC_ASSERT static_assert | ||||||
|  | #else | ||||||
|  |   #define STATIC_ASSERT _Static_assert | ||||||
|  | #endif | ||||||
|  |  | ||||||
| /** | /** | ||||||
|   Macro that returns a pointer to the data structure that contains a specified field of |   Macro that returns a pointer to the data structure that contains a specified field of | ||||||
|   that data structure.  This is a lightweight method to hide information by placing a |   that data structure.  This is a lightweight method to hide information by placing a | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user