Skip to contentSkip to conversation

Make gnu89 support explicit

PATCH Superseded Steffan Karger 2 participants 3 messages Aug 28, 2016 – Sep 16, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make gnu89 support explicit

In the release/2.3 branch we support gnu89, basically to keep pre-2015 MSVC happy. Old gcc (<5) defaulted to gnu89. But gcc 5+ and clang default to gnu11/c11. This patch makes our gnu89 support explicit, such these newer compilers will also point out gnu89 violations to developers.

---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)
configure.ac +1 -0
index 62b389e..e5c7ef1 100644
@@ -1069,6 +1069,7 @@ if test "${enable_pkcs11}" = "yes"; then
 	)
 fi
 
+CFLAGS="${CFLAGS} -std=gnu89"
 if test "${enable_pedantic}" = "yes"; then
 	enable_strict="yes"
 	CFLAGS="${CFLAGS} -pedantic"
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/1 Make gnu89 support explicit

In the release/2.3 branch we support gnu89, basically to keep pre-2015 MSVC happy. Old gcc (<5) defaulted to gnu89. But gcc 5+ and clang default to gnu11/c11. This patch makes our gnu89 support explicit, such these newer compilers will also point out gnu89 violations to developers.

v2: only set -std=gnu89 if no -std flag is present in $CFLAGS

---
 configure.ac | 6 ++++++
 1 file changed, 6 insertions(+)
configure.ac +6 -0
index 62b389e..af24392 100644
@@ -1069,6 +1069,12 @@ if test "${enable_pkcs11}" = "yes"; then
 	)
 fi
 
+# Set -std=gnu89 unless user already specified a -std=
+case "${CFLAGS}" in
+  *-std=*) ;;
+  *)       CFLAGS="${CFLAGS} -std=gnu89" ;;
+esac
+
 if test "${enable_pedantic}" = "yes"; then
 	enable_strict="yes"
 	CFLAGS="${CFLAGS} -pedantic"
Signature · 1 line
2.7.4
#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ACK. This works well on CentOS 5, so this change makes sense as this makes the compiler behaviour more predictable in regards to C standards.

This will most possibly break non-GNU compilers though (Solaris and AIX?). But as this behaviour can be overridden by setting the CFLAGS to a -std those compilers accepts, I consider this reasonable. The recommended way to set CFLAGS is like this:

     ./configure CFLAGS="-std=c99"

This ensures that if configure decides it is needed to do a re-configure run, it will preserve the CFLAGS setting.

Your patch has been applied to the release/2.3 branch.

commit 130c27b1f24a33c77e01b2cf82c3427699153967

Author: Steffan Karger
Date:   Fri Sep 16 17:40:36 2016 +0200
     Make gnu89 support explicit

     Signed-off-by: Steffan Karger <[email protected]...>
     Acked-by: David Sommerseth <[email protected]...>
     Message-Id: [email protected]...
     URL: http://www.mail-archive.com/search?l=mid&[email protected]...
     Signed-off-by: David Sommerseth <[email protected]...>

- --
kind regards,

David Sommerseth

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBAgAGBQJX3CATAAoJEIbPlEyWcf3y3LoP/17RIq3BOQi+mpG1APbyaokE e9neSJYjIDIcRMFA0daaqap3q6cXoapzeafWQ/LdJbZv5hc4pC2gYemBltqwagV+ SS7MQTCu5oqnw2E86c3T7+EjzmwnbJk0/KB+fsjH9q25OEVpOHZ9ztQ4vsn60pCr fPoB6OmNjJqJBbgKGm2bY6U0rhl/Wkap00NhiIiSQPJY24d7jZ6ZCIeIq+muvELc Zj325IbZsxDmsAPN309dJ3LAEZX2f13PfaLiMdNu7ZnKFUcnJBIGpXYoDWAaIuY6 G42hkHz8KP0f8y0ZNxiOwLWNCCePEmYiRLwHkW4mZSoPewSMy2hZbWcYnFWVUT96 HISpoyRGRJZQ75Vo6vee19ck4Mr+b7/JUmL6cP7UgY8TmlRRAAYeU626OYe/j+r9 9rG9ulAuFUAv0KJeqLKLzFj+3krN8eRdelzuAMcBfQPAb4n/1YAQk71KzsRIyO2T PWOE8kGkSm2GRCZnlQPgD5lEx9p7bHKFEJylpnFCd5uiFAPfVvvz25UREU/sd7Si x2Q5Oxq8XtJF9UEqutWieutkGYPR5/OQifFb2+sJpXN1GNoa0qbZw8CZ9EVJCywe 8O2u7GVbNFAw5vy0Ri+XQXXF3y2Vc3clVfwg0LQC1GhxylAQQboKWKksLRKVna1G Op6mg2SglMw4wYEkLG1K
=lCei
-----END PGP SIGNATURE-----