Skip to content

CODING_STANDARDS.md: establish C99 as the implementation language #10631

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

Merged
merged 1 commit into from
Feb 20, 2023

Conversation

MaxKellermann
Copy link
Contributor

PHP 8 switched to C99, but did not documented that anywhere.

After @derickr rejected a pull request on timelib
(derickr/timelib#141 (comment)) because my suggested change removed compile-time checks for fixed-width integer types, pointing out that they are optional in the C99 standard, @nikic disagreed with using uint_least8_t instead (which is guaranteed to be available), stating that "We already make extensive use of uint8_t, you can assume it exists" (#10621 (review)).

In order to avoid such confusion in the future, let's document this architecture requirement.

PHP 8 switched to C99, but did not documented that anywhere.

After @derickr rejected a pull request on timelib
(derickr/timelib#141 (comment))
because my suggested change removed compile-time checks for
fixed-width integer types, pointing out that they are optional in the
C99 standard, @nikic disagreed with using `uint_least8_t` instead
(which is guaranteed to be available), stating that "We already make
extensive use of uint8_t, you can assume it exists"
(php#10621 (review)).

In order to avoid such confusion in the future, let's document this
architecture requirement.
@nikic
Copy link
Member

nikic commented Feb 20, 2023

Just as a side node, timelib is a library independent from php-src, so both can have different requirements regarding the supported C standard and compiler support. (As long as the php-src requirement >= the timelib requirement.)

That said, the only reasonable environment in which the uintN_t types may not be available is an environment where CHAR_BITS is not 8. Clang doesn't even support such targets in the first place :)

@MaxKellermann
Copy link
Contributor Author

Of course, we all know the world has settled on machines where all of those are available and nobody bothers to support theoretical machines where it isn't, but that assumption should be documented.

Prior to PHP8, these configure-/compile-time checks existed not to support those theoretical machines, but because C89 did not have any fixed-width integers. The removal of those checks does not break PHP (or timelib) on theoretical machines; it was already broken before, and those checks did not help with that.

@Girgias Girgias merged commit 5bfd3fa into php:master Feb 20, 2023
@MaxKellermann MaxKellermann deleted the coding_standards_c99 branch March 7, 2023 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants