commit 4797899b24d35873211cf0cd1a2a373e2db3c528
parent 611069d07c14bf7ace7a75fa2bc9147db8ac097d
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 29 Dec 2025 21:15:44 +0100
Change __format into __fortify_format to fix conflict with LLVM libcxx
LLVM libcxx (20.1.8) also defines a `__format` macro in it's
C++ locale header (`/usr/include/c++/v1/locale`).
Fixes: https://github.com/jvoisin/fortify-headers/issues/76
Diffstat:
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/fortify-headers.h b/include/fortify-headers.h
@@ -68,9 +68,9 @@
#endif
#if __has_attribute (format)
-#define __format(...) __attribute__ ((format (__VA_ARGS__)))
+#define __fortify__format(...) __attribute__ ((format (__VA_ARGS__)))
#else
-#define __format(...)
+#define __fortify__format(...)
#endif
#if __has_attribute (__diagnose_if)
diff --git a/include/stdio.h b/include/stdio.h
@@ -76,7 +76,7 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n,
return __orig_fwrite(__d, __n, __m, __f);
}
-__format(printf, 3, 0)
+__fortify__format(printf, 3, 0)
__access(write_only, 1, 2)
__access(read_only, 3)
_FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n,
@@ -89,7 +89,7 @@ _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n,
return __orig_vsnprintf(__s, __n, __f, __v);
}
-__format(printf, 2, 0)
+__fortify__format(printf, 2, 0)
__access(write_only, 1)
__access(read_only, 2)
_FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f,
@@ -123,7 +123,7 @@ _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f,
* 3) not implementing these under clang, which is what we do for now
*/
-__format(printf, 3, 4)
+__fortify__format(printf, 3, 4)
_FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n,
const char *__f, ...)
{
@@ -134,7 +134,7 @@ _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n,
return __orig_snprintf(__s, __n, __f, __builtin_va_arg_pack());
}
-__format(printf, 2, 3)
+__fortify__format(printf, 2, 3)
_FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...)
{
size_t __b = __bos(__s, 0);