Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124707 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id D26301A00B7 for ; Thu, 1 Aug 2024 22:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722551331; bh=+S662vAi3guwFClC2dSPALJhOSY1fMvvHVd/Y6BvoJI=; h=Date:From:To:Subject:In-Reply-To:References:From; b=mq5+p2bp1JkalI+iboO7ytgTc7WLL4PopD6mY6sAg2eFqdSYhA23O9w4SPyPf0SqN PX7FS8OkBlQ/3KvjMW3uBjEJeIMnrs0CS3BNvM58veaW03KnitZCk51izETgTZ6Jqa iFKedsvaDS0xUPoLgJPd2Fo8eez9E+Ltgdqiaq0krnTqmiLZ3yUIkWEiN2QLYbql/Y 7SPVw4dMEruZcUDfvAAVEDtjopCjT8H2vN6tq2i5JbRLka/153TcVmWl8eBTvjYW+E hjUdPO8R7O3KXRgQRgTvss9fOkxXWZORtqCV8hC0NJr3czlcFRWrFcDUroQmcQqIPr KaszdD/OCMkNQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D06AC180042 for ; Thu, 1 Aug 2024 22:28:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: *** X-Spam-Status: No, score=3.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from xdebug.org (xdebug.org [82.113.146.227]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 1 Aug 2024 22:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722551229; bh=+S662vAi3guwFClC2dSPALJhOSY1fMvvHVd/Y6BvoJI=; h=Date:From:To:Subject:In-Reply-To:References:From; b=T1/lHM5Cjv0hS1n+dpM9IoAThull1R3+3G6EiuC4liWma+wpkuZ0Nm85M05raGHoc 1riwUgnbLBTbJ2KZyRC2Tr31RMzmWeydkgj+/e2QBsep4d4Rj2dE578h4j9CIEw7cb WY3OSVyKP2KqTHhbOu/9PiBoHYh3wbnf4QNCH+LvSKxDJ4Fg3PEMz0GEkngYFifa8f chj1F2uwLr6KIqHcmGGkEllRP2hNQX6UJ3l25PVeLvk548+6mMn7KlHmI729IS+/3r KQ0NxqdeKAgl5MyVMKpHXEx6NImZji3KlrwvYMHgJgP6Iu3lv9DpG4pHdUxVAxwXJo DNsoR+We2Dxag== Received: from [127.0.0.1] (host86-183-121-93.range86-183.btcentralplus.com [86.183.121.93]) by xdebug.org (Postfix) with ESMTPSA id 3E80D10C054; Thu, 01 Aug 2024 23:26:15 +0100 (BST) Date: Thu, 01 Aug 2024 23:26:10 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] Require C11 in PHP 8.4 User-Agent: K-9 Mail for Android In-Reply-To: References: Message-ID: <30A26099-E558-4C99-B47A-47E30D5CA456@php.net> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: derick@php.net (Derick Rethans) On 1 August 2024 22:57:36 BST, Ilija Tovilo wr= ote: >Hi everyone > >We've gotten a bug report about compile errors in the PHP 8=2E4 alpha on >old C99 compilers (and on some modern compilers when passing the >-std=3Dc99 flag)=2E Specifically, C99 does not support typedef >redeclarations, which is a C11 feature=2E > >```c >// some_header=2Eh >typedef struct _zval_struct zval; >void some_func(zval *zv); > >// zend_types=2Eh >struct _zval_struct { =2E=2E=2E }; >typedef struct _zval_struct zval; >``` > >Some headers might want to forward declare zval so that zend_types=2Eh >doesn't have to be included=2E The two primary reasons you might want to >avoid that are 1=2E to reduce compile times if the header is very large >and 2=2E to prevent recursive header dependencies=2E > >However, in C99 this code is actually illegal if both of these headers >end up being included, because redeclarations of typedefs are not >allowed=2E To fix it, the typedef must be removed and the signatures >must refer to the struct directly=2E > >```c >// some_header=2Eh >struct _zval_struct; >void some_func(struct _zval_struct *zv); >``` > >I started fixing these in a PR [1] which required more changes than >expected=2E After a short discourse, we were wondering whether it might >be better to switch to a newer C standard instead=2E Our coding >standards [2] currently specify that compiling php-src requires C99=2E >The Unix installation page on php=2Enet [3] claims it is ANSI C, which >is certainly outdated=2E There have been suggestions to require C11 for >a while, which should be well supported by all compilers shipped with >maintained distributions=2E > >GCC gained support for C11 in 4=2E7 [4], LLVM Clang in 3=2E1, both >released in 2012=2E For context, Debian Bullseye comes with GCC 10=2E2 >[5], Ubuntu Focal Fossa comes with GCC 9=2E3 [6], RHEL 8 comes with GCC >8=2Ex [7]=2E=20 =20 Even Debian wheezy (out of extended LTS support) or Ubuntu 14=2E04 have GC= C 4=2E7, so that seems OK=2E=20 How about Clang (for OSX) though? I can't check that easily=2E=20 cheers=20 Derick=20