# No #\[no\_mangle\]

**URL:** <https://internals.rust-lang.org/t/no-no-mangle/3973>\
**Category:** language design\
**Created:** [September 1, 2016, 9:40pm UTC](https://internals.rust-lang.org/t/no-no-mangle/3973 "2016-09-01T21:40:59Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![kornel](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kornel/32/2711_2.png) [@kornel](https://internals.rust-lang.org/u/kornel)\
**Post date:** [September 2, 2016, 10:33pm UTC](https://internals.rust-lang.org/t/no-no-mangle/3973/6 "2016-09-02T22:33:36Z")

</div>

> [@nikomatsakis](#):
>
> I am sympathetic to this. To be perfectly honest, I hadn't really considered that calling Rust code directly from C was so common

It's indeed very rare for Rust programs and libraries that have only Rust API. However, I'm using Rust to write a library for use in C and other languages. In a library with C-compatible interface _every_ public function has to have `#[no_mangle]`.

I've scanned 8000 files I have in `~/.cargo/registry` as well as Rust's own repo (excluding test cases):

- Inherited #[mangle] `exception_cleanup` src/libpanic\_unwind/lib.rs

- Inherited #[mangle] `locking_function` openssl-sys-0.7.1/src/lib.rs

- Inherited #[mangle] `thread_id` openssl-sys-0.7.1/src/lib.rs

- Inherited #[mangle] `shutdown` log-0.3.4/src/lib.rs

- Inherited #[mangle] `raw_verify` openssl/src/ssl/mod.rs

- Inherited #[mangle] `subtransport_free` git2/src/transport.rs

- Inherited #[no\_mangle] `rust_eh_personality` src/libpanic\_unwind/lib.rs

- Inherited #[no\_mangle] `block_context_copy` block/src/lib.rs

- Inherited #[no\_mangle] `locking_function` openssl-sys/src/lib.rs

- Inherited #[no\_mangle] `ppapi_instance_created` ppapi/src/lib/lib.rs

- Inherited #[no\_mangle] `ppapi_instance_destroyed` ppapi/src/lib/lib.rs

- Public #[no\_mangle] `__rust_allocate` src/liballoc\_jemalloc/lib.rs

- Public #[no\_mangle] `__rust_allocate` src/liballoc\_system/lib.rs

- Public #[no\_mangle] `__rust_deallocate` src/liballoc\_jemalloc/lib.rs

- Public #[no\_mangle] `__rust_deallocate` src/liballoc\_system/lib.rs

- Public #[no\_mangle] `__rust_maybe_catch_panic` src/libpanic\_abort/lib.rs

- Public #[no\_mangle] `__rust_maybe_catch_panic` src/libpanic\_unwind/lib.rs

- Public #[no\_mangle] `__rust_reallocate` src/liballoc\_jemalloc/lib.rs

- Public #[no\_mangle] `__rust_reallocate` src/liballoc\_system/lib.rs

- Public #[no\_mangle] `__rust_reallocate_inplace` src/liballoc\_jemalloc/lib.rs

- Public #[no\_mangle] `__rust_reallocate_inplace` src/liballoc\_system/lib.rs

- Public #[no\_mangle] `__rust_start_panic` src/libpanic\_abort/lib.rs

- Public #[no\_mangle] `__rust_start_panic` src/libpanic\_unwind/lib.rs

- Public #[no\_mangle] `__rust_usable_size` src/liballoc\_jemalloc/lib.rs

- Public #[no\_mangle] `__rust_usable_size` src/liballoc\_system/lib.rs

- Public #[no\_mangle] `rust_eh_personality` src/libpanic\_abort/lib.rs

- Public #[no\_mangle] `rust_eh_personality_catch` src/libpanic\_unwind/lib.rs

These would be affected:

- Public #[mangle] `callback` glutin/src/api/win32/callback.rs -- used as `pub(crate)`

- Public #[mangle] `curl_progress_fn` curl/src/ffi/easy.rs -- used as a callback

- Public #[mangle] `did_change_focus` ppapi/src/lib/lib.rs -- used as `pub(crate)`

- Public #[mangle] `did_change_view` ppapi/src/lib/lib.rs

- Public #[mangle] `did_create` ppapi/src/lib/lib.rs

- Public #[mangle] `did_destroy` ppapi/src/lib/lib.rs

- Public #[mangle] `graphics_context_lost` ppapi/src/lib/lib.rs

- Public #[mangle] `handle_document_load` ppapi/src/lib/lib.rs

- Public #[mangle] `handle_input_event` ppapi/src/lib/lib.rs

- Public #[mangle] `handle_message` ppapi/src/lib/lib.rs

- Public #[mangle] `mz_crc32` flate2/src/ffi.rs -- used as `pub(crate)`? Probably doesn't have to be extern "C"

- Public #[mangle] `mz_deflateInit2` flate2/src/ffi.rs

- Public #[mangle] `mz_inflateInit2` flate2/src/ffi.rs

- Public #[mangle] `open` libc/rust/src/liblibc/lib.rs -- odd, looks like an error?

- Public #[mangle] `FD_SET` libc-0.x/src/lib.rs - [pub extern fn functions without #[no\_mangle] · Issue #376 · rust-lang/libc · GitHub](https://github.com/rust-lang/libc/issues/376)

- Public #[mangle] `FD_ZERO` libc-0.x/src/lib.rs

- Public #[mangle] `WCOREDUMP` libc-0.x/src/lib.rs

- Public #[mangle] `WEXITSTATUS` libc-0.x/src/lib.rs

- Public #[mangle] `WIFCONTINUED` libc-0.x/src/lib.rs

- Public #[mangle] `WIFEXITED` libc-0.x/src/lib.rs

- Public #[mangle] `WTERMSIG` libc-0.x/src/lib.rs

- Public #[mangle] `_WSTATUS` libc-0.x/src/lib.rs

---

_[View the full topic](https://internals.rust-lang.org/t/no-no-mangle/3973)._
