[Libguestfs] [p2v PATCH 5/5] Define the GCC version macro

Pino Toscano ptoscano at redhat.com
Fri Jul 12 15:03:23 UTC 2019


Carry over the GUESTFS_GCC_VERSION macros from libguestfs, that defines
the GCC version as single number; also, rename it to P2V_GCC_VERSION,
and limit it to GCC (defined to 0 for any other compiler).
---
 p2v.h | 7 +++++++
 ssh.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/p2v.h b/p2v.h
index 66c245e..52842bd 100644
--- a/p2v.h
+++ b/p2v.h
@@ -32,6 +32,13 @@
 
 #include "guestfs-utils.h"
 
+#if defined(__GNUC__) && !defined(__clang__)
+# define P2V_GCC_VERSION \
+    (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+#else
+# define P2V_GCC_VERSION 0
+#endif
+
 /* All disks / removable media / network interfaces discovered
  * when the program started.  Do not change these.
  */
diff --git a/ssh.c b/ssh.c
index c11ef11..59d1891 100644
--- a/ssh.c
+++ b/ssh.c
@@ -314,7 +314,7 @@ cache_ssh_identity (struct config *config)
  * thinks might grow to an unbounded size.  Since we control
  * extra_args, this is not in fact a problem.
  */
-#if defined(__GNUC__) && GUESTFS_GCC_VERSION >= 40800 /* gcc >= 4.8.0 */
+#if P2V_GCC_VERSION >= 40800 /* gcc >= 4.8.0 */
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wstack-usage="
 #endif
@@ -575,7 +575,7 @@ start_ssh (unsigned spawn_flags, struct config *config,
   return h;
 }
 
-#if defined(__GNUC__) && GUESTFS_GCC_VERSION >= 40800 /* gcc >= 4.8.0 */
+#if P2V_GCC_VERSION >= 40800 /* gcc >= 4.8.0 */
 #pragma GCC diagnostic pop
 #endif
 
-- 
2.21.0




More information about the Libguestfs mailing list