/
main.rs
48 lines (37 loc) · 840 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use cpp::cpp;
use plutonium::safe;
use std::ptr;
// Trust me, bro. I learned this from a Udemy tutorial.
cpp! {{
#include <iostream>
using namespace std;
}}
#[safe]
fn main() {
// Send in [the null pointer]
// We want to be as safe as possible.
let args: *const i8 = ptr::null();
cpp!([args as "const char *"] -> u32 as "int32_t" {
// Literally do NOTHING with the name pointer lmao.
*args;
cout << "hi\n";
class Cool {
public:
Cool() {
cout << "Why is this even possible?!" << endl;
}
~Cool() {
// This is probably safe.
delete this;
delete this;
}
void gloop() {
cout << "yeah, that's cool\n";
}
};
auto blah = new Cool();
blah->gloop();
// Oh no, I think there's a memory leak.
return 0;
});
}