Skip to content

Initial implementation of @extern builtin #7182

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

Merged
merged 2 commits into from
Nov 21, 2020
Merged

Conversation

LemonBoy
Copy link
Contributor

I heard from the grapevine somebody needs weak extern symbols.

MVP based on our previous discussion & failed attempts.

@andrewrk
Copy link
Member

I'm actually a little bit further along than this in a local branch - my strategy is to append to a list and then iterate over it in do_code_gen. It works for things in a comptime scope too

@andrewrk
Copy link
Member

andrewrk commented Nov 21, 2020

ok my code is not at a point where it's working though so I'm tempted to merge this as is since we have to re-implement it in stage2 anyway

would this unblock #4503 as-is?

@LemonBoy
Copy link
Contributor Author

LemonBoy commented Nov 21, 2020

I'm actually a little bit further along than this in a local branch

The only missing thing is documentation and (hopefully) a few changes to let the parser allow @extern, right now it rejects that with a syntax error because extern is a keyword (?).

Edit: The parser part was really easy.

would this unblock #4503 as-is?

AFAIR I needed this to check for _DYNAMIC being defined or not. Yes, this should be enough.

@suirad
Copy link
Contributor

suirad commented Nov 21, 2020

How does this compare with @export(fnname, "out name", .Weak)?

When I was using the above I was hoping it would work like the extern.

@LemonBoy
Copy link
Contributor Author

How does this compare with @export(fnname, "out name", .Weak)?

That exports a weak symbol, extern lets you import weak (or strong) symbols.

Make it recognize extern/export symbols prefixed by @ as a builtin
rather than stand-alone keywords.
@andrewrk andrewrk merged commit 7dcda5b into ziglang:master Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants