21

I've tried reading various github issues trying to track down what the difference is and just ended up confused.

#[no_mangle]
pub extern fn foo() {
   ...
}

vs.

#[no_mangle]
pub extern "C" fn foo() {
   ...
}
marathon
  • 7,881
  • 17
  • 74
  • 137

1 Answers1

24

There is no difference because, as the reference says:

By default external blocks assume that the library they are calling uses the standard C ABI on the specific platform.

extern "C" -- This is the same as extern fn foo(); whatever the default your C compiler supports.

An issue was created to always require explicitly stating extern "C" but the RFC has been refused.

There is an issue in fmt-rfcs about "should we format extern "C" fn as that or extern fn?".

Community
  • 1
  • 1
Stargateur
  • 24,473
  • 8
  • 65
  • 91