php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65761 comma at end of enumerator list
Submitted: 2013-09-25 17:19 UTC Modified: 2018-08-28 20:55 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: xuefer at gmail dot com Assigned: carusogabriel (profile)
Status: Closed Package: Compile Warning
PHP Version: 5.5.4 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 - 22 = ?
Subscribe to this entry?

 
 [2013-09-25 17:19 UTC] xuefer at gmail dot com
Description:
------------
php/Zend/zend.h:283:15: warning: comma at end of enumerator list [-pedantic]

typedef enum {
  SUCCESS =  0,
  FAILURE = -1,  <- line 283
} ZEND_RESULT_CODE;

This is not allowed in C89, but allowed in C99. yet not allowed in C++
I'm not sure if this is consider as a bug as PHP 5.5 is moving forward for new 
compiler by dropping support to older ones. But it's better to fix it for building 
extension that support multiple PHP versions


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-13 21:57 UTC] peterkokot at gmail dot com
Hello, sorry for bumping this bug report after several years. The main issue is that currently there isn't any coding style defined for the PHP source code where this would be agreed on - trailing commas in enums or not.

This is so much more relevant to rethink if fixing this with the C99 standard at the door is important today. With C99 in PHP the trailing commas will be legit unless agreed otherwise with the coding style.

From what I'm currently reading, the LLVM coding style guide doesn't use them. Neither does the default clang format tool enforce any particular trailing comma style. The Google C++ uses trailing commas. Also the git differences can be a bit nicer.

The "trend" seems to me is going into trailing commas direction. Also, PHP has now trailing commas available in functions, arrays etc :). I'd say to check out what is useful and set it in the coding guide and/or define the clang format rule and stick to that in the PHP src code base. Now, about fixing these C89 specific warnings or not... We can simply add a fix for this bug report via pull request and define the particular code style for enums in the future if needed...
 [2018-08-28 20:55 UTC] petk@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: carusogabriel
 [2018-08-28 20:55 UTC] petk@php.net
Hello, this has been addressed in this pull request:
https://github.com/php/php-src/pull/3451

and since the trailing commas are ok in enums today, this can be closed. In case of further issues let us know.

Thank you for reporting issues and helping us make PHP better.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Dec 01 13:05:53 2022 UTC