ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
adi_drivers_general.h
1 
45 #ifndef ADI_DRIVERS_GENERAL__H
46 #define ADI_DRIVERS_GENERAL__H
47 
48 
49 /* Macros related to alignment in the different toolchains supported */
50 
51 /*
52  * These macros are designed to be used as follows:
53  * ADI_ALIGNED_PRAGMA(<required_alignment>)
54  * <variable_declaration> ADI_ALIGNED_ATTRIBUTE(<required_alignment>)
55  */
56 
57 #if defined ( __ICCARM__ )
58 /*
59 * IAR MISRA C 2004 error suppressions.
60 *
61 *
62 * Pm120 (rule 19.10): In the definition of a function-like macro each parameter
63 * shall be enclosed in parenthesis.
64 * This is not possible in attributes and pragmas
65 * Pm154 (rule 19.13): The # and ## preprocessor operators shall not be used.
66 * We need to do this to abstract the macros for the
67 * different toolchains
68 */
69 #pragma diag_suppress=Pm120,Pm154
70 #endif
71 
72 #define PRAGMA(x) _Pragma(#x)
73 #define ATTRIBUTE(x) __attribute__((x))
74 
75 #if defined (__GNUC__)
76  /* Gcc uses attributes */
77  #define ADI_ALIGNED_PRAGMA(num)
78  #define ADI_ALIGNED_ATTRIBUTE(num) ATTRIBUTE(aligned(num))
79  #define ADI_UNUSED_ATTRIBUTE ATTRIBUTE(unused)
80 #elif defined ( __ICCARM__ )
81  /* IAR uses a pragma */
82  #define ADI_ALIGNED_ATTRIBUTE(num)
83  #define ADI_ALIGNED_PRAGMA(num) PRAGMA(data_alignment=num)
84  #define ADI_UNUSED_ATTRIBUTE
85 #elif defined (__CC_ARM)
86  /* Keil uses a decorator which is placed in the same position as pragmas */
87  #define ADI_ALIGNED_ATTRIBUTE(num)
88  #define ADI_ALIGNED_PRAGMA(num) __align(##num)
89  #define ADI_UNUSED_ATTRIBUTE ATTRIBUTE(unused)
90 #else
91 #error "Toolchain not supported"
92 #endif
93 
94 
95 #if defined ( __ICCARM__ )
96 #pragma diag_default=Pm120,Pm154
97 #endif
98 #endif /* ADI_DRIVERS_GENERAL__H */