# translate-c: better support for static local variables · gitcafe/zig

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

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

Visibility: public

Requested revision: ea4a25287eb65e639fd75d425f320663e6e8dca1

Requested commit: ea4a25287eb65e639fd75d425f320663e6e8dca1

Commit: ea4a25287eb65e639fd75d425f320663e6e8dca1

Tree: b207a5d47fc1b3b42bca6ad8aa10b2283779255c

Author: Evan Haas

Committer: Veikka Tuominen

## Message

```
translate-c: better support for static local variables

Don't move static local variables into the top-level scope since this
can cause name clashes if subsequently-defined variables or parameters
in different scopes share the name.

Instead, use a variable within a struct so that the variable's lexical
scope does not change. This solution was suggested by @LemonBoy

Note that a similar name-shadowing problem exists with `extern` variables
declared within block scope, but a different solution will be needed since
they do need to be moved to the top-level scope and we can't rename them.

```

## Parents

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

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