* lib/c++defs.h (_GL_CXXALIASWARN_2): Treat clang like gcc 4.2.
* lib/stdio.in.h (fwrite, fwrite_unlocked): Likewise.
* lib/warn-on-use.h (_GL_WARN_ON_USE, _GL_WARN_ON_USE_CXX): Likewise.
* lib/libc-config.h (__GNUC_PREREQ): Override glibc's definition to
handle clang in disguise.
+2024-08-27 Bruno Haible <bruno@clisp.org>
+
+ Improve support for clang on Windows.
+ * lib/c++defs.h (_GL_CXXALIASWARN_2): Treat clang like gcc 4.2.
+ * lib/stdio.in.h (fwrite, fwrite_unlocked): Likewise.
+ * lib/warn-on-use.h (_GL_WARN_ON_USE, _GL_WARN_ON_USE_CXX): Likewise.
+ * lib/libc-config.h (__GNUC_PREREQ): Override glibc's definition to
+ handle clang in disguise.
+
2024-08-27 Bruno Haible <bruno@clisp.org>
Explicitly exclude clang when we test for a GCC version >= 4.3.
_GL_WARN_ON_USE (func, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
-# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
# define _GL_CXXALIASWARN_2(func,namespace) \
extern __typeof__ (func) func
# else
/* From glibc <features.h>. */
+#if defined __clang__
+ /* clang really only groks GNU C 4.2, regardless of its value of __GNUC__. */
+# undef __GNUC_PREREQ
+# define __GNUC_PREREQ(maj, min) ((maj) < 4 + ((min) <= 2))
+#endif
#ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
which sometimes causes an unwanted diagnostic for fwrite calls.
This affects only function declaration attributes under certain
versions of gcc and clang, and is not needed for C++. */
-# if (0 < __USE_FORTIFY_LEVEL \
+# if (0 < __USE_FORTIFY_LEVEL \
&& __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
- && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \
+ && (3 < __GNUC__ + (4 <= __GNUC_MINOR__) || defined __clang__) \
&& !defined __cplusplus)
# undef fwrite
# undef fwrite_unlocked
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
-# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_clang function parameters_and_attributes \
__attribute__ ((__diagnose_if__ (1, msg, "warning")))
-# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_gcc function parameters_and_attributes