inc/ecu/attributes.h Source File

ECU: inc/ecu/attributes.h Source File
ECU
attributes.h
Go to the documentation of this file.
1 
14 #ifndef ECU_ATTRIBUTES_H_
15 #define ECU_ATTRIBUTES_H_
16 
17 #if defined(ECU_DOXYGEN)
33  #define ECU_ATTRIBUTE_NORETURN
34 
40  #define ECU_ATTRIBUTE_PACKED
41 
47  #define ECU_ATTRIBUTE_SECTION(x_)
61  #define ECU_ATTRIBUTE_UNUSED
63 #else
64  /* ECU_ATTRIBUTE_NORETURN - Critical attribute. */
65  #if defined(__cplusplus) && (__cplusplus >= 201103L) /* Using C++11 and up. */
66  #define ECU_ATTRIBUTE_NORETURN [[noreturn]]
67  #elif !defined(__cplusplus) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && (__STDC_VERSION__ < 202311L) /* Using C11 to C17. */
68  #define ECU_ATTRIBUTE_NORETURN _Noreturn
69  #elif !defined(__cplusplus) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) /* Using C23 and up. */
70  #define ECU_ATTRIBUTE_NORETURN [[noreturn]]
71  #elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* Compiling with GCC with extensions enabled (attributes are compiler extensions not supported in ISO C). */
72  #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95 || (__GNUC_MINOR__ == 95 && __GNUC_PATCHLEVEL__ > 2))) /* GCC >= v2.95.3. Oldest version in GCC docs. */
73  #define ECU_ATTRIBUTE_NORETURN __attribute__((noreturn))
74  #endif
75  #endif
76 
77  /* ECU_ATTRIBUTE_PACKED - Critical attribute. */
78  #if defined(__GNUC__) && !defined(__STRICT_ANSI__) /* Compiling with GCC with extensions enabled (attributes are compiler extensions not supported in ISO C). */
79  #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95 || (__GNUC_MINOR__ == 95 && __GNUC_PATCHLEVEL__ > 2))) /* GCC >= v2.95.3. Oldest version in GCC docs. */
80  #define ECU_ATTRIBUTE_PACKED __attribute__((packed))
81  #endif
82  #endif
83 
84  /* ECU_ATTRIBUTE_SECTION - Critical attribute. */
85  #if defined(__GNUC__) && !defined(__STRICT_ANSI__) /* Compiling with GCC with extensions enabled (attributes are compiler extensions not supported in ISO C). */
86  #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95 || (__GNUC_MINOR__ == 95 && __GNUC_PATCHLEVEL__ > 2))) /* GCC >= v2.95.3. Oldest version in GCC docs. */
87  #define ECU_ATTRIBUTE_SECTION(x_) __attribute__((section(x_)))
88  #endif
89  #endif
90 
91  /* ECU_ATTRIBUTE_SECTION - Non-critical attribute. */
92  #if defined(__GNUC__) && !defined(__STRICT_ANSI__) /* Compiling with GCC with extensions enabled (attributes are compiler extensions not supported in ISO C). */
93  #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95 || (__GNUC_MINOR__ == 95 && __GNUC_PATCHLEVEL__ > 2))) /* GCC >= v2.95.3. Oldest version in GCC docs. */
94  #define ECU_ATTRIBUTE_UNUSED __attribute__((unused))
95  #endif
96  #endif
97 
98  /* Non-critical attributes. */
99  #ifndef ECU_ATTRIBUTE_UNUSED
100  #define ECU_ATTRIBUTE_UNUSED
101  #endif
102 #endif /* ECU_DOXYGEN */
103 
104 #endif /* ECU_ATTRIBUTES_H_ */