Skip to content
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

Shadowing in C header files #2676

Closed
NBonaparte opened this issue Jun 14, 2019 · 3 comments
Closed

Shadowing in C header files #2676

NBonaparte opened this issue Jun 14, 2019 · 3 comments
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. frontend Tokenization, parsing, AstGen, Sema, and Liveness. translate-c C to Zig source translation feature (@cImport)
Milestone

Comments

@NBonaparte
Copy link
Contributor

Importing the Wayland client header file (@cInclude("wayland-client.h")) results in, among other errors, this:

error: redefinition of 'wl_display'
pub fn wl_display_get_registry(wl_display: ?*struct_wl_display) ?*struct_wl_registry {

note: previous definition is here
pub const wl_display = struct_wl_display;

This is because in wayland-client-protocol.h the argument name is the same as the type:

static inline struct wl_registry *
wl_display_get_registry(struct wl_display *wl_display)

Many of the inline functions included in the header also exhibit the same issue.

Should translate-c have some sort of renaming mechanism to work around this?

@andrewrk
Copy link
Member

Should translate-c have some sort of renaming mechanism to work around this?

It does have such a mechanism - it seems to not be detecting this situation properly.

@andrewrk andrewrk added this to the 0.6.0 milestone Jun 16, 2019
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Jun 16, 2019
@andrewrk
Copy link
Member

Translate-c is in the middle of a transition from C++ to zig (see #1964), so even though this is a bug in the C++ version, I'm going to try to solve it by putting more effort towards the self-hosted version, which is why I gave it 0.6.0 milestone.

@andrewrk andrewrk added the translate-c C to Zig source translation feature (@cImport) label Jun 16, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Oct 23, 2019
@andrewrk andrewrk added contributor friendly This issue is limited in scope and/or knowledge of Zig internals. frontend Tokenization, parsing, AstGen, Sema, and Liveness. and removed stage1 The process of building from source via WebAssembly and the C backend. labels Jan 2, 2020
@daurnimator
Copy link
Contributor

Fixed in master.

@andrewrk andrewrk modified the milestones: 0.7.0, 0.6.0 Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. frontend Tokenization, parsing, AstGen, Sema, and Liveness. translate-c C to Zig source translation feature (@cImport)
Projects
None yet
Development

No branches or pull requests

3 participants