Search
 
SCRIPT & CODE EXAMPLE
 

RUST

armanriazi•rust•concept•mangling

We also need to add a #[no_mangle] annotation to tell the Rust compiler not to mangle the name of this function. Mangling is when a compiler changes the name we’ve given a function to a different name that contains more information for other parts of the compilation process to consume but is less human readable. Every programming language compiler mangles names slightly differently, so for a Rust function to be nameable by other languages, we must disable the Rust compiler’s name mangling.

In the following example, we make the call_from_c function accessible from C code, after it’s compiled to a shared library and linked from C:



#![allow(unused)]
fn main() {
#[no_mangle]
pub extern "C" fn call_from_c() {
    println!("Just called a Rust function from C!");
}
}
Comment

PREVIOUS NEXT
Code Example
Rust :: rustdoc 
Rust :: armanriazi•rust•thread•spawning 
Rust :: armanriazi•rust•concept•datarace•rustaceans 
Rust :: Rust Options Some None using closures 
Rust :: armanriazi•rust•thread•channel 
Rust :: create a rust project Inside the folder 
Rust :: rust tuple vs vec 
Rust :: rust random float between 0 and 1 
Lua :: luau make rainbow part 
Lua :: lua not equal 
Lua :: roblox make region 
Lua :: roblox __index and __newindex 
Lua :: luau loop players 
Lua :: remote function unable to cast value to object 
Lua :: creating new functions using script roblox 
Lua :: lua create file 
Lua :: roblox number generator 
Lua :: lua string split 
Lua :: how to make text different colors in LUA terminal 
Lua :: lua hash table length 
Lua :: attempt to call a string value lua 
Lua :: awesomewm wibar configuration transparent 
Lua :: roblox studio buying robux 
Matlab :: find location of max value in array matlab 
Matlab :: how to get the highest power of polynomial matlab 
Matlab :: matlab invert image 
Basic :: add firefox 
Elixir :: jason elixir 
Elixir :: elixir list 
Scala :: how to make anonymous function in scala 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =