From 830240edf187997b72bdc9032c25aa298a74850b Mon Sep 17 00:00:00 2001 From: John Bowler Date: Sun, 22 Sep 2024 15:14:51 -0700 Subject: [PATCH] build system: require ISO-C when building libpng Previously the build systems would accept any old compiler and those compilers would define any old symbol or macro name. ISO (well, ANSI) defined a strict set of symbols/macros which may be defined by the implementation leaving the remainder for application programs. Adding a requirement for an ISO-C compiler (any version) ensures that a check for name clashes on one compiler (with a sufficient level of diagnostics) works for every ISO-C compiler. In other words if it builds on one it builds on all. The check is in pngpriv.h; the same restrictions do not apply to code that calls the public interface of libpng, only to the compiler used to build ligpng. Signed-off-by: John Bowler --- pngpriv.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pngpriv.h b/pngpriv.h index 79de6e9e92..6c9a599840 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -23,6 +23,16 @@ #ifndef PNGPRIV_H #define PNGPRIV_H +/* Compiler functionality. For building libpng (though not necessarily for + * using libpng) a C compiler conformant to at least the original ANSI-C + * standard (C89, ISO-C90) is required. + */ +#if __STDC__ != 1 +# error A compiler compliant with ISO-C90 is required to build libpng +#endif + +/* TODO: check __STDC_VERSION__ (defined in ISO-C95) */ + /* Feature Test Macros. The following are defined here to ensure that correctly * implemented libraries reveal the APIs libpng needs to build and hide those * that are not needed and potentially damaging to the compilation.