Skip to content

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

2 participants