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

emit translate-c warnings as comments rather than (omitted by default) messages to stderr #2259

Closed
andrewrk opened this issue Apr 11, 2019 · 2 comments
Labels
accepted This proposal is planned. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. frontend Tokenization, parsing, AstGen, Sema, and Liveness. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. standard library This issue involves writing Zig code for the standard library. translate-c C to Zig source translation feature (@cImport)
Milestone

Comments

@andrewrk
Copy link
Member

Right now you have to do this to observe warnings from translate-c:

foo.h

struct Foo {
    unsigned a : 1;
    unsigned b : 7;
};

terminal

$ zig translate-c foo.h --verbose-cimport
test.h:2:14: warning: struct Foo demoted to opaque type - has bitfield
pub const struct_Foo = @OpaqueType();
...

This is not obvious, and results in confusion such as in #2257. Further, the warnings are not well connected to @cImport expressions.

Instead, the warnings should be in the AST itself, as comments, perhaps even doc comments describing the type that could not be translated.

This wasn't my idea; it came from someone in the Zig community but I don't remember where.

Note that modifications to translate-c are subject to #1964. If working on a patch for this issue, please try to use the C API where possible (and maybe even help the conversion effort).

@andrewrk andrewrk added contributor friendly This issue is limited in scope and/or knowledge of Zig internals. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. accepted This proposal is planned. stage1 The process of building from source via WebAssembly and the C backend. labels Apr 11, 2019
@andrewrk andrewrk added this to the 0.5.0 milestone Apr 11, 2019
@andrewrk
Copy link
Member Author

This can be done in the self-hosted version only (See #1964).

@andrewrk andrewrk added frontend Tokenization, parsing, AstGen, Sema, and Liveness. standard library This issue involves writing Zig code for the standard library. and removed stage1 The process of building from source via WebAssembly and the C backend. labels Apr 30, 2019
@andrewrk andrewrk added the translate-c C to Zig source translation feature (@cImport) label Jun 16, 2019
@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Aug 21, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Oct 23, 2019
@Vexu
Copy link
Member

Vexu commented Jan 2, 2020

Closed by #4025

@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
accepted This proposal is planned. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. frontend Tokenization, parsing, AstGen, Sema, and Liveness. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. standard library This issue involves writing Zig code for the standard library. translate-c C to Zig source translation feature (@cImport)
Projects
None yet
Development

No branches or pull requests

3 participants