# translate-c: do not translate macros which use arguments as struct/union/enum names · gitcafe/zig

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

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

Visibility: public

Requested revision: 0fa8cf44f69dcb00dacf180d88ebfa09bc462120

Requested commit: 0fa8cf44f69dcb00dacf180d88ebfa09bc462120

Commit: 0fa8cf44f69dcb00dacf180d88ebfa09bc462120

Tree: 99b05b6dad404a5008677de5b056adec44db24f2

Author: mlugg

Committer: mlugg

## Message

````
translate-c: do not translate macros which use arguments as struct/union/enum names

Consider this C macro:
```c
#define FOO(x) struct x
```

Previously, translate-c did not detect that the `x` in the body referred
to the argument, so wrongly translated this code as using the
nonexistent `struct_x`. Since undefined identifiers are noticed in
AstGen, this prevents the translated file from being usable at all.

translate-c now instead detects this case and emits an appropriate
compile error in the macro's place.

````

## Parents

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

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