]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - include/openssl/macros.h
include/openssl/macros.h: Rework OPENSSL_FUNC for div C standards
[thirdparty/openssl.git] / include / openssl / macros.h
index da5d1556809045f8dae213f9426e9903479a044e..a06b8695221f5c96b117111205c0d342bea335be 100644 (file)
 #  endif
 # endif
 
+/*
+ * __func__ was standardized in C99, so for any compiler that claims
+ * to implement that language level or newer, we assume we can safely
+ * use that symbol.
+ *
+ * GNU C also provides __FUNCTION__ since version 2, which predates
+ * C99.  We can, however, only use this if __STDC_VERSION__ exists,
+ * as it's otherwise not allowed according to ISO C standards (C90).
+ * (compiling with GNU C's -pedantic tells us so)
+ *
+ * If none of the above applies, we check if the compiler is MSVC,
+ * and use __FUNCTION__ if that's the case.
+ *
+ * If all these possibilities are exhausted, we give up and use a
+ * static string.
+ */
 # ifndef OPENSSL_FUNC
-#  if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#   define OPENSSL_FUNC __func__
-#  elif defined(__STRICT_ANSI__)
-#   define OPENSSL_FUNC "(unknown function)"
-#  elif defined(_MSC_VER) || (defined(__GNUC__) && __GNUC__ >= 2)
-#   define OPENSSL_FUNC __FUNCTION__
-#  elif defined(__FUNCSIG__)
-#   define OPENSSL_FUNC __FUNCSIG__
+#  if defined(__STDC_VERSION__)
+#   if __STDC_VERSION__ >= 199901L
+#    define OPENSSL_FUNC __func__
+#   elif defined(__GNUC__) && __GNUC__ >= 2
+#    define OPENSSL_FUNC __FUNCTION__
+#   endif
+#  elif defined(_MSC_VER)
+#    define OPENSSL_FUNC __FUNCTION__
 #  else
 #   define OPENSSL_FUNC "(unknown function)"
 #  endif