Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for compiler typedef redeclaration support at configure-time #15397

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions CODING_STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
28 changes: 28 additions & 0 deletions Zend/Zend.m4
Original file line number Diff line number Diff line change
@@ -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
iluuu1994 marked this conversation as resolved.
Show resolved Hide resolved
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;
petk marked this conversation as resolved.
Show resolved Hide resolved
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?
]))])
])

iluuu1994 marked this conversation as resolved.
Show resolved Hide resolved
dnl
dnl ZEND_CHECK_FLOAT_PRECISION
dnl
Expand Down Expand Up @@ -157,6 +180,7 @@ AC_CHECK_FUNC([sigsetjmp],,
[AC_MSG_FAILURE([Required sigsetjmp not found.])],
[#include <setjmp.h>])])

ZEND_CHECK_TYPEDEF_REDECL
ZEND_CHECK_STACK_DIRECTION
ZEND_CHECK_FLOAT_PRECISION
ZEND_DLSYM_CHECK
Expand Down Expand Up @@ -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
Expand Down
Loading