mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-22 15:57:46 +02:00
Add minimal no_std example.
This commit is contained in:
parent
27820629e2
commit
f71a86d942
@ -237,6 +237,7 @@
|
|||||||
|
|
||||||
- [Welcome](welcome-bare-metal.md)
|
- [Welcome](welcome-bare-metal.md)
|
||||||
- [`no_std`](bare-metal/no_std.md)
|
- [`no_std`](bare-metal/no_std.md)
|
||||||
|
- [A minimal example](bare-metal/minimal.md)
|
||||||
- [`core`]()
|
- [`core`]()
|
||||||
- [`alloc`]()
|
- [`alloc`]()
|
||||||
- [Microcontrollers]()
|
- [Microcontrollers]()
|
||||||
|
22
src/bare-metal/minimal.md
Normal file
22
src/bare-metal/minimal.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# A minimal `no_std` program
|
||||||
|
|
||||||
|
```rust,editable
|
||||||
|
#![no_main]
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
|
#[panic_handler]
|
||||||
|
fn panic(_panic: &PanicInfo<'_>) -> ! {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
* This will compile to an empty binary.
|
||||||
|
* `std` provides a panic handler; without it we must provide our own.
|
||||||
|
* Depending on the target, you may need to compile with `panic = "abort"` to avoid an error about
|
||||||
|
`eh_personality`.
|
||||||
|
|
||||||
|
</details>
|
Loading…
x
Reference in New Issue
Block a user