ADuCM4x50 Device Drivers API Reference Manual  Release 4.0.0.0
adi_drivers_general.h
1 
13 #ifndef ADI_DRIVERS_GENERAL__H
14 #define ADI_DRIVERS_GENERAL__H
15 
16 
17 /* Macros related to alignment in the different toolchains supported */
18 
19 /*
20  * These macros are designed to be used as follows:
21  * ADI_ALIGNED_PRAGMA(<required_alignment>)
22  * <variable_declaration> ADI_ALIGNED_ATTRIBUTE(<required_alignment>)
23  */
24 
25 #if defined ( __ICCARM__ )
26 /*
27 * IAR MISRA C 2004 error suppressions.
28 *
29 *
30 * Pm120 (rule 19.10): In the definition of a function-like macro each parameter
31 * shall be enclosed in parenthesis.
32 * This is not possible in attributes and pragmas
33 * Pm154 (rule 19.13): The # and ## preprocessor operators shall not be used.
34 * We need to do this to abstract the macros for the
35 * different toolchains
36 */
37 #pragma diag_suppress=Pm120,Pm154
38 #endif
39 
40 #define PRAGMA(x) _Pragma(#x)
41 #define ATTRIBUTE(x) __attribute__((x))
42 
43 #if defined (__GNUC__)
44  /* Gcc uses attributes */
45  #define ADI_ALIGNED_PRAGMA(num)
46  #define ADI_ALIGNED_ATTRIBUTE(num) ATTRIBUTE(aligned(num))
47  #define ADI_UNUSED_ATTRIBUTE ATTRIBUTE(unused)
48 #elif defined ( __ICCARM__ )
49  /* IAR uses a pragma */
50  #define ADI_ALIGNED_ATTRIBUTE(num)
51  #define ADI_ALIGNED_PRAGMA(num) PRAGMA(data_alignment=num)
52  #define ADI_UNUSED_ATTRIBUTE
53 #elif defined (__CC_ARM)
54  /* Keil uses a decorator which is placed in the same position as pragmas */
55  #define ADI_ALIGNED_ATTRIBUTE(num)
56  #define ADI_ALIGNED_PRAGMA(num) __align(##num)
57  #define ADI_UNUSED_ATTRIBUTE ATTRIBUTE(unused)
58 #else
59 #error "Toolchain not supported"
60 #endif
61 
62 
63 #if defined ( __ICCARM__ )
64 #pragma diag_default=Pm120,Pm154
65 #endif
66 #endif /* ADI_DRIVERS_GENERAL__H */