# C backend: emit decls sorted by dependencies · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/234d94e42b832dd17eb9144f5523e03ef4fa8eb3)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 234d94e42b832dd17eb9144f5523e03ef4fa8eb3

Requested commit: 234d94e42b832dd17eb9144f5523e03ef4fa8eb3

Commit: 234d94e42b832dd17eb9144f5523e03ef4fa8eb3

Tree: 700e631cc733543083dc9bd5b6a53e0dedcc1ec5

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
C backend: emit decls sorted by dependencies

The C backend is the only backend that requires each decl to be output
in an order that satisfies the dependency graph. Here it is implemented
with a simple algorithm based on a `remaining_decls` set, using the
`dependencies` edges that are already stored for each Decl.

This satisfies incremental compilation as well as how `zig test` works,
which calls `updateDecl` on `test_functions`.

```

## Parents

- [8e93ec6d2491246c841c2f983bb48152b8de2837](https://git.cafe/gitcafe/zig/commit/8e93ec6d2491246c841c2f983bb48152b8de2837?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/234d94e42b832dd17eb9144f5523e03ef4fa8eb3?format=markdown)
