Jump to content
Main menu
Main menu
move to sidebar
hide
Social
Discord
Facebook
Twitter
Explore
Languages
Tasks
Random page
Rosetta Code
Search
Search
Create account
Log in
Personal tools
Dark mode
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Call a foreign-language function: Difference between revisions
Page
Discussion
English
Read
View source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
View source
View history
Refresh
General
Special pages
Printable version
Get shortened URL
← Older edit
Newer edit →
Call a foreign-language function
(view source)
Revision as of 00:25, 4 July 2016
360 bytes removed
,
8 years ago
→{{header|Rust}}
Revision as of 00:24, 4 July 2016
(
view source
)
rosettacode>KartD
(Added Rust version)
← Older edit
Revision as of 00:25, 4 July 2016
(
view source
)
rosettacode>KartD
(
→{{header|Rust}}
)
Newer edit →
Line 1,892:
</lang>
=={{header|Rust}}==
<lang rust>extern crate libc;
//c function that returns the sum of two integers
extern {
fn add_input(in1: libc::c_int, in2: libc::c_int) -> libc::c_int;
}
fn main() {
let (in1, in2) = (5, 4);
let output = unsafe {
add_input(in1, in2) };
assert!( (output == (in1 + in2) ),"Error in sum calculation") ;
}</lang>
Anonymous user
rosettacode>KartD
Cookies help us deliver our services. By using our services, you agree to our use of cookies.
More information
OK
Toggle limited content width