diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -349,9 +349,7 @@ /* * Compiler-dependent macros to declare that functions take printf-like - * or scanf-like arguments. They are null except for versions of gcc - * that are known to support the features properly (old versions of gcc-2 - * didn't permit keeping the keywords out of the application namespace). + * or scanf-like arguments. */ #define __printflike(fmtarg, firstvararg) \ __attribute__((__format__ (__printf__, fmtarg, firstvararg))) @@ -363,8 +361,16 @@ #define __strftimelike(fmtarg, firstvararg) \ __attribute__((__format__ (__strftime__, fmtarg, firstvararg))) -#define __printf0like(fmtarg, firstvararg) \ - __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) +/* + * Like __printflike, but allows fmtarg to be NULL. Previously, FreeBSD had a + * special printf0 for this, but that's the behavior for both clang and gcc >= + * 11. Other compilers get no warnings due to false positives with NULL args. + */ +#if defined(__clang__) || __GNUC_PREREQ__(11, 0) +#define __printf0like(fmtarg, firstvararg) __printflike(fmtarg, firstvararg) +#else +#define __printf0like(fmtarg, firstvararg) +#endif #define __strong_reference(sym,aliassym) \ extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))