You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/conditional-compilation.md
+61-2Lines changed: 61 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ r[cfg.intro]
31
31
*Conditionally compiled source code* is source code that is compiled only under certain conditions.
32
32
33
33
r[cfg.attributes-macro]
34
-
Source code can be made conditionally compiled using the [`cfg`] and [`cfg_attr`][attributes] and the built-in [`cfg` macro].
34
+
Source code can be made conditionally compiled using the [`cfg`] and [`cfg_attr`][attributes] and the built-in [`cfg!`] and [`cfg_select!`][macros].
35
35
36
36
r[cfg.conditional]
37
37
Whether to compile can depend on the target architecture of the compiled crate, arbitrary values passed to the compiler, and other things further described below.
@@ -436,17 +436,76 @@ let machine_kind = if cfg!(unix) {
436
436
println!("I'm running on a {} machine!", machine_kind);
437
437
```
438
438
439
+
r[cfg.cfg_select]
440
+
### The `cfg_select` macro
441
+
442
+
r[cfg.cfg_select.intro]
443
+
The built-in [`cfg_select!`][std::cfg_select] macro can be used to select code at compile-time based on multiple configuration predicates.
0 commit comments