diff --git a/CODING_STANDARDS.md b/CODING_STANDARDS.md index 5fb2586eadd78..c599194ed50e3 100644 --- a/CODING_STANDARDS.md +++ b/CODING_STANDARDS.md @@ -9,12 +9,10 @@ rewritten to comply with these rules. 1. Document your code in source files and the manual. (tm) -1. PHP is implemented in C99. +1. PHP is implemented in C11. For instance, the optional fixed-width integers from stdint.h (int8_t, int16_t, int32_t, int64_t and their unsigned counterparts) are supposed to be available. - However, some features (most notably variable-length arrays) which are not - supported by all relevant compilers, must not be used. 1. Functions that are given pointers to resources should not free them. diff --git a/Zend/Zend.m4 b/Zend/Zend.m4 index b7b44fb140872..7ffdfcbf9b583 100644 --- a/Zend/Zend.m4 +++ b/Zend/Zend.m4 @@ -1,5 +1,28 @@ dnl This file contains Zend specific autoconf macros. +dnl +dnl ZEND_CHECK_TYPEDEF_REDECL +dnl +dnl Check whether the compiler supports typedef redeclaractions. For example, +dnl GCC 4.2 on Mac OS X 10.6 emits a redefinition of typedef error by default. +dnl +AC_DEFUN([ZEND_CHECK_TYPEDEF_REDECL], [dnl +AC_CACHE_CHECK([if compiler allows typedef redeclarations], + [php_cv_have_typedef_redecl], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [dnl + typedef int mytype; + typedef int mytype; + mytype var; + (void)var; + ])], + [php_cv_have_typedef_redecl=yes], + [php_cv_have_typedef_redecl=no])]) +AS_VAR_IF([php_cv_have_typedef_redecl], [no], + [AC_MSG_FAILURE(m4_text_wrap([ + Compiler does not support typedef redeclarations. Does it support C11? + ]))]) +]) + dnl dnl ZEND_CHECK_FLOAT_PRECISION dnl @@ -157,6 +180,7 @@ AC_CHECK_FUNC([sigsetjmp],, [AC_MSG_FAILURE([Required sigsetjmp not found.])], [#include ])]) +ZEND_CHECK_TYPEDEF_REDECL ZEND_CHECK_STACK_DIRECTION ZEND_CHECK_FLOAT_PRECISION ZEND_DLSYM_CHECK @@ -206,6 +230,10 @@ AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes], AX_CHECK_COMPILE_FLAG([-fno-common], [CFLAGS="-fno-common $CFLAGS"],, [-Werror]) +dnl Suppress the Clang typedef redefinition warnings if it has enabled C99 mode. +AX_CHECK_COMPILE_FLAG([-Wno-typedef-redefinition], + [CFLAGS="$CFLAGS -Wno-typedef-redefinition"],, + [-Werror]) ZEND_CHECK_ALIGNMENT ZEND_CHECK_SIGNALS