Clang on Windows does not necessarily have '__GNUC__' defined when
compiling OvS on Windows. However, it supports the attributes such as
'__unused__' and the rest in this macro-defined branch. Instead of
defining '__GNUC__' with a flag '-fgnuc_version=X' (X is a version),
which may have a larger impact, I think that it is better to not define
it unless absolutely necessary to avoid having to deal with potential
compatability issues and third-party libraries. For example, POSIX
threads library for Windows checks for GNU C version if it supports
'__declspec' whenever '__GNUC__' is defined.


Signed-off-by: Sergey Madaminov <[email protected]>

---
 include/openvswitch/compiler.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/openvswitch/compiler.h b/include/openvswitch/compiler.h
index cf009f826..3fe5fc4b5 100644
--- a/include/openvswitch/compiler.h
+++ b/include/openvswitch/compiler.h
@@ -37,7 +37,7 @@
 #define OVS_NO_RETURN
 #endif
 
-#if __GNUC__ && !__CHECKER__
+#if (__clang__ || __GNUC__) && !__CHECKER__
 #define OVS_UNUSED __attribute__((__unused__))
 #define OVS_PRINTF_FORMAT(FMT, ARG1) __attribute__((__format__(printf, FMT, 
ARG1)))
 #define OVS_SCANF_FORMAT(FMT, ARG1) __attribute__((__format__(scanf, FMT, 
ARG1)))
-- 
2.25.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to