Original, some code directly judge the value of these macros, but linux ICC compiler will report error as "zero used for undefined preprocessing identifier". So it is better judge whether these macros are defined before accessing their value.
2, Use #if defined() style to replace #ifdef style.
It is good to keep consistent style for this case.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7596
6f19259b-4bc3-4df7-8a09-
765794883524
//\r
// Make sure we are using the correct packing rules per EFI specification\r
//\r
//\r
// Make sure we are using the correct packing rules per EFI specification\r
//\r
+#if !defined(__GNUC__)\r
#pragma pack()\r
#endif\r
\r
#pragma pack()\r
#endif\r
\r
+#if defined(__INTEL_COMPILER)\r
//\r
// Disable ICC's remark #869: "Parameter" was never referenced warning.\r
// This is legal ANSI C code so we disable the remark that is turned on with -Wall\r
//\r
// Disable ICC's remark #869: "Parameter" was never referenced warning.\r
// This is legal ANSI C code so we disable the remark that is turned on with -Wall\r
+#if defined(_MSC_EXTENSIONS)\r
\r
//\r
// Disable warning that make it impossible to compile at /W4\r
\r
//\r
// Disable warning that make it impossible to compile at /W4\r
// No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
//\r
\r
// No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
//\r
\r
+ #if defined(_MSC_EXTENSIONS)\r
\r
//\r
// use Microsoft C complier dependent integer width types \r
\r
//\r
// use Microsoft C complier dependent integer width types \r
// use the correct C calling convention. All protocol member functions and\r
// EFI intrinsics are required to modify their member functions with EFIAPI.\r
//\r
// use the correct C calling convention. All protocol member functions and\r
// EFI intrinsics are required to modify their member functions with EFIAPI.\r
//\r
+#if defined(_MSC_EXTENSIONS)\r
///\r
/// Microsoft* compiler specific method for EFIAPI calling convension\r
/// \r
#define EFIAPI __cdecl \r
#else\r
///\r
/// Microsoft* compiler specific method for EFIAPI calling convension\r
/// \r
#define EFIAPI __cdecl \r
#else\r
+ #if defined(__GNUC__)\r
///\r
/// GCC specific method for EFIAPI calling convension\r
/// \r
///\r
/// GCC specific method for EFIAPI calling convension\r
/// \r
// if the /OPT:REF linker option is used. We defined a macro as this is a \r
// a non standard extension\r
//\r
// if the /OPT:REF linker option is used. We defined a macro as this is a \r
// a non standard extension\r
//\r
+#if defined(_MSC_EXTENSIONS)\r
///\r
/// Remove global variable from the linked image if there are no references to \r
/// it after all compiler and linker optimizations have been performed.\r
///\r
/// Remove global variable from the linked image if there are no references to \r
/// it after all compiler and linker optimizations have been performed.\r
//\r
// For symbol name in GNU assembly code, an extra "_" is necessary\r
//\r
//\r
// For symbol name in GNU assembly code, an extra "_" is necessary\r
//\r
#if defined(linux)\r
#define ASM_PFX(name) name\r
#else\r
#if defined(linux)\r
#define ASM_PFX(name) name\r
#else\r
+#if defined(__INTEL_COMPILER)\r
//\r
// Disable ICC's remark #869: "Parameter" was never referenced warning.\r
// This is legal ANSI C code so we disable the remark that is turned on with -Wall\r
//\r
// Disable ICC's remark #869: "Parameter" was never referenced warning.\r
// This is legal ANSI C code so we disable the remark that is turned on with -Wall\r
+#if defined(_MSC_EXTENSIONS)\r
//\r
// Disable warning that make it impossible to compile at /W4\r
// This only works for Microsoft* tools\r
//\r
// Disable warning that make it impossible to compile at /W4\r
// This only works for Microsoft* tools\r
-#if (__STDC_VERSION__ < 199901L)\r
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ < 199901L)\r
//\r
// No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
//\r
\r
//\r
// No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
//\r
\r
+ #if defined(_MSC_EXTENSIONS)\r
//\r
// use Microsoft C complier dependent integer width types\r
//\r
//\r
// use Microsoft C complier dependent integer width types\r
//\r
///\r
typedef char INT8;\r
#else\r
///\r
typedef char INT8;\r
#else\r
+ #if defined(_EFI_P64)\r
//\r
// P64 - pointers being 64-bit and longs and ints are 32-bits.\r
//\r
//\r
// P64 - pointers being 64-bit and longs and ints are 32-bits.\r
//\r
// use the correct C calling convention. All protocol member functions and\r
// EFI intrinsics are required to modify their member functions with EFIAPI.\r
//\r
// use the correct C calling convention. All protocol member functions and\r
// EFI intrinsics are required to modify their member functions with EFIAPI.\r
//\r
+#if defined(_MSC_EXTENSIONS)\r
///\r
/// Microsoft* compiler specific method for EFIAPI calling convension\r
/// \r
///\r
/// Microsoft* compiler specific method for EFIAPI calling convension\r
/// \r
// if the /OPT:REF linker option is used. We defined a macro as this is a\r
// a non standard extension\r
//\r
// if the /OPT:REF linker option is used. We defined a macro as this is a\r
// a non standard extension\r
//\r
+#if defined(_MSC_EXTENSIONS)\r
///\r
/// Remove global variable from the linked image if there are no references to \r
/// it after all compiler and linker optimizations have been performed.\r
///\r
/// Remove global variable from the linked image if there are no references to \r
/// it after all compiler and linker optimizations have been performed.\r
//\r
// Make sure we are using the correct packing rules per EFI specification\r
//\r
//\r
// Make sure we are using the correct packing rules per EFI specification\r
//\r
+#if !defined(__GNUC__)\r
#pragma pack()\r
#endif\r
\r
\r
#pragma pack()\r
#endif\r
\r
\r
+#if defined(__INTEL_COMPILER)\r
//\r
// Disable ICC's remark #869: "Parameter" was never referenced warning.\r
// This is legal ANSI C code so we disable the remark that is turned on with -Wall\r
//\r
// Disable ICC's remark #869: "Parameter" was never referenced warning.\r
// This is legal ANSI C code so we disable the remark that is turned on with -Wall\r
+#if defined(_MSC_EXTENSIONS)\r
\r
//\r
// Disable warning that make it impossible to compile at /W4\r
\r
//\r
// Disable warning that make it impossible to compile at /W4\r
// No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
//\r
\r
// No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
//\r
\r
+ #if defined(_MSC_EXTENSIONS)\r
//\r
// use Microsoft C complier dependent integer width types \r
//\r
//\r
// use Microsoft C complier dependent integer width types \r
//\r
///\r
typedef char INT8;\r
#else\r
///\r
typedef char INT8;\r
#else\r
+ #if defined(_EFI_P64)\r
//\r
// P64 - pointers being 64-bit and longs and ints are 32-bits.\r
//\r
//\r
// P64 - pointers being 64-bit and longs and ints are 32-bits.\r
//\r
// use the correct C calling convention. All protocol member functions and\r
// EFI intrinsics are required to modify their member functions with EFIAPI.\r
//\r
// use the correct C calling convention. All protocol member functions and\r
// EFI intrinsics are required to modify their member functions with EFIAPI.\r
//\r
+#if defined(_MSC_EXTENSIONS)\r
///\r
/// Microsoft* compiler specific method for EFIAPI calling convension\r
/// \r
#define EFIAPI __cdecl \r
///\r
/// Microsoft* compiler specific method for EFIAPI calling convension\r
/// \r
#define EFIAPI __cdecl \r
+#elif defined(__GNUC__)\r
///\r
/// Define the standard calling convention reguardless of optimization level.\r
/// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI\r
///\r
/// Define the standard calling convention reguardless of optimization level.\r
/// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI\r
// if the /OPT:REF linker option is used. We defined a macro as this is a \r
// a non standard extension\r
//\r
// if the /OPT:REF linker option is used. We defined a macro as this is a \r
// a non standard extension\r
//\r
+#if defined(_MSC_EXTENSIONS)\r
///\r
/// Remove global variable from the linked image if there are no references to \r
/// it after all compiler and linker optimizations have been performed.\r
///\r
/// Remove global variable from the linked image if there are no references to \r
/// it after all compiler and linker optimizations have been performed.\r
//\r
// For symbol name in GNU assembly code, an extra "_" is necessary\r
//\r
//\r
// For symbol name in GNU assembly code, an extra "_" is necessary\r
//\r
#if defined(linux)\r
#define ASM_PFX(name) name\r
#else\r
#if defined(linux)\r
#define ASM_PFX(name) name\r
#else\r