Skip to content

Hello world #598

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 5 commits into from
Jul 27, 2021
Merged

Hello world #598

merged 5 commits into from
Jul 27, 2021

Conversation

philberty
Copy link
Member

@philberty philberty commented Jul 26, 2021

extern "C" {
    fn puts(s: *const i8);
}

fn main() {
    unsafe {
        let a = "Hello World\0";
        let b = a as *const str;
        let c = b as *const i8;
        puts(c);
    }
}

Fixes #421

This adds extern block compilation support. It currently assumes the C abi
and does not perform any name mangling. It does not support varadic
arguments yet but its the initial support to get this working.

Fixes #421
Varadic functions are only allowed in extern functions as far as I know.
@philberty philberty linked an issue Jul 27, 2021 that may be closed by this pull request
@philberty
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 27, 2021

Build succeeded:

@bors bors bot merged commit f76ddb4 into master Jul 27, 2021
@philberty philberty deleted the phil/extern-fns branch July 28, 2021 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when extern function item has no return type Can't call extern functions
1 participant