Skip to content

CODING_STANDARDS.md: add rules for #include directives #10338

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

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 19 additions & 0 deletions CODING_STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,25 @@ rewritten to comply with these rules.
codebase but should not be refactored, unless larger refactoring around that
code is taking place.

## C Headers

1. Include only the headers (`*.h`) that are really needed. Consider
using [iwyu](https://include-what-you-use.org/).

1. Use struct/union forward declarations to eliminate `#include`
directives if possible.

1. If some headers are needed only in some build configurations,
enclose them in the same `#if` that also guards the use of its
definitions.

1. Each source file (`*.c`) should include its own header file first
to ensure that the header's `#includes` are complete.

1. Header inclusions are ordered this way: its own header first, then
PHP headers, then third-party library headers, then system headers
(e.g. libc, POSIX).

## Testing

1. Extensions should be well tested using `*.phpt` tests. Read more at
Expand Down