[vlc-devel] [PATCH 1/1] build: avoid annoying _FORTIFY_SOURCE warnings (fixes #17341)

Janne Grunau janne-vlc at jannau.net
Wed Jan 2 12:54:49 CET 2019

fixed patch with the duplicate "#if defined ..." removed

Some toolchains predefine _FORTIFY_SOURCE resulting in countless
_FORTIFY_SOURCE is redefined warnings. Using _FORTIFY_SOURCE without
compiler optimizations also generates warnings.
_FORTIFY_SOURCE is a reserved identifier in C99 ("All identifiers that
begin with an underscore and either an uppercase letter or another
underscore are always reserved for any use.") so the toolchain is
perfectly free to predefine it.
 configure.ac | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index d3df6e254e..d419737124 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,7 +36,12 @@ dnl
-AC_DEFINE([_FORTIFY_SOURCE], 2, [Define to 2 to get glibc warnings.])
+  [/* Enable compile-time and run-time bounds-checking, and some warnings,
+   without upsetting glibc 2.15+ or toolchains predefining _FORTIFY_SOURCE */
+#if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
+# define _FORTIFY_SOURCE 2
 AC_DEFINE([_FILE_OFFSET_BITS], 64, [Define to 64 for large files support.])
 AC_DEFINE([__LIBVLC__],, [Define within the LibVLC source code tree.])
 AC_DEFINE([WIN32_LEAN_AND_MEAN],, [Define to limit the scope of <windows.h>.])

More information about the vlc-devel mailing list