Skip to content

Commit b44a1f3

Browse files
committed
Clarify conditional compilation
Introduction of `cfg` attribute and `cfg!` macro operators is misleading. `cfg!` macro has nothing to do with conditional compilation, but it can be used for run-time conditional checks. It is `cfg` attribute that enables conditional compilation. Clarify the responsibilities of the operators.
1 parent c106d16 commit b44a1f3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/attribute/cfg.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# `cfg`
22

3-
Conditional compilation is possible through two different operators:
3+
Configuration conditional checks are possible through two different operators:
44

55
* the `cfg` attribute: `#[cfg(...)]` in attribute position
66
* the `cfg!` macro: `cfg!(...)` in boolean expressions
77

8-
Both utilize identical argument syntax.
8+
While the former enables conditional compilation, the latter allows for run-time
9+
checks. Both utilize identical argument syntax.
910

1011
```rust,editable
1112
// This function only gets compiled if the target OS is linux
@@ -22,7 +23,7 @@ fn are_you_on_linux() {
2223
2324
fn main() {
2425
are_you_on_linux();
25-
26+
2627
println!("Are you sure?");
2728
if cfg!(target_os = "linux") {
2829
println!("Yes. It's definitely linux!");

0 commit comments

Comments
 (0)