Skip to content

Can't call extern functions #421

@bjorn3

Description

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

fn main() {
    unsafe {
        puts("foo\0" as *const str as *const i8);
    }
}

as is this gives

<source>:6:5: fatal error: Failed to lower expr: [UnsafeBlockExpr:
  outer attributes: noneBlockExpr:

  outer attributes: none
  inner attributes: none
 statements: 
 ExprStmtWithoutBlock:
  CallExpr: 
   outer attributes: none
 Function expr: puts
 Call params:
  foo as *const str as *const i8
 final expression: none

]
    6 |     unsafe {
      |     ^
compilation terminated.

without unsafe block it gives

<source>:6:5: error: unknown root segment in path puts lookup puts
    6 |     puts("foo\0" as *const str as *const i8);
      |     ^

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions