aboutsummaryrefslogtreecommitdiff
path: root/book/src/by-example/tips.md
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-16 21:05:56 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-16 21:05:56 +0000
commit3511e915b5261ca11928ced3c05fa5ce1cabb138 (patch)
tree46081c204b0424802ed88ce61f6e750105aa91e2 /book/src/by-example/tips.md
parentc2fbb2848851e32b78e79ff9e919538b7d5ab8a0 (diff)
parent22140fbc49b16e422652542371d3b389b2a5fbeb (diff)
Merge #116
116: v0.4.0 r=japaric a=japaric Co-authored-by: Jorge Aparicio <jorge@japaric.io>
Diffstat (limited to 'book/src/by-example/tips.md')
-rw-r--r--book/src/by-example/tips.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/book/src/by-example/tips.md b/book/src/by-example/tips.md
index c163328..5057c80 100644
--- a/book/src/by-example/tips.md
+++ b/book/src/by-example/tips.md
@@ -20,6 +20,20 @@ rewrite code. If you consistently use `lock`s to access the data behind shared
resources then your code will continue to compile when you change the priority
of tasks.
+## Conditional compilation
+
+You can use conditional compilation (`#[cfg]`) on resources (`static [mut]`
+items) and tasks (`fn` items). The effect of using `#[cfg]` attributes is that
+the resource / task will *not* be injected into the prelude of tasks that use
+them (see `resources`, `spawn` and `schedule`) if the condition doesn't hold.
+
+The example below logs a message whenever the `foo` task is spawned, but only if
+the program has been compiled using the `dev` profile.
+
+``` rust
+{{#include ../../../examples/cfg.rs}}
+```
+
## Running tasks from RAM
The main goal of moving the specification of RTFM applications to attributes in