Skip to contentSkip to conversation

Improve check for GCC compiler version

PATCH Applied Khem Raj 2 participants 2 messages Mar 23, 2025 – Jun 2, 2025 Memory technology devices (MTD)

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 Improve check for GCC compiler version

When using unreleased compiler has version like 15.0.1 and that test fails because __GNUC_MINOR__ < 1 becomes true, therefore check for full version string which is more rubust.

---
 ubifs-utils/common/atomic.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
ubifs-utils/common/atomic.h +5 -1
index f287d43..95754b2 100644
@@ -2,8 +2,12 @@
 #ifndef __ATOMIC_H__
 #define __ATOMIC_H__
 
+#define GCC_VERSION (__GNUC__ * 10000 \
+                     + __GNUC_MINOR__ * 100 \
+                     + __GNUC_PATCHLEVEL__)
+
 /* Check GCC version, just to be safe */
-#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC_MINOR__ < 1)
+#if GCC_VERSION < 40100
 # error atomic.h works only with GCC newer than version 4.1
 #endif /* GNUC >= 4.1 */
 

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/