diff options
author | Vitaly Cheptsov via Groups.Io <vit9696=protonmail.com@groups.io> | 2019-08-17 07:28:14 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2019-09-11 22:30:16 +0800 |
commit | 204ae9da230ecbf0910c21acac7aa5d5e8cbb8d0 (patch) | |
tree | 6843ec439c9fd788f87ba341dc725cee9180a163 /MdePkg | |
parent | 5e5abfcab4c2962005be89c951a86f55db27555e (diff) | |
download | edk2-204ae9da230ecbf0910c21acac7aa5d5e8cbb8d0.tar.gz edk2-204ae9da230ecbf0910c21acac7aa5d5e8cbb8d0.tar.bz2 edk2-204ae9da230ecbf0910c21acac7aa5d5e8cbb8d0.zip |
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>
Diffstat (limited to 'MdePkg')
-rw-r--r-- | MdePkg/Include/Base.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index ce20b5f01d..ec096133ba 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -844,6 +844,20 @@ typedef UINTN *BASE_LIST; #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
that data structure. This is a lightweight method to hide information by placing a
public data structure inside a larger private data structure and using a pointer to
|