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
+19-49Lines changed: 19 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,8 +37,7 @@ 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.
38
38
39
39
r[cfg.predicate]
40
-
Each form of conditional compilation takes a _configuration predicate_ that
41
-
evaluates to true or false. The predicate is one of the following:
40
+
Each form of conditional compilation takes a _configuration predicate_ that evaluates to true or false. The predicate is one of the following:
42
41
43
42
r[cfg.predicate.option]
44
43
* A configuration option. The predicate is true if the option is set, and false if it is unset.
@@ -74,8 +73,7 @@ r[cfg.options.set]
74
73
## Set configuration options
75
74
76
75
r[cfg.options.general]
77
-
Which configuration options are set is determined statically during the
78
-
compilation of the crate.
76
+
Which configuration options are set is determined statically during the compilation of the crate.
79
77
80
78
r[cfg.options.target]
81
79
Some options are _compiler-set_ based on data about the compilation.
@@ -84,8 +82,7 @@ r[cfg.options.other]
84
82
Other options are _arbitrarily-set_ based on input passed to the compiler outside of the code.
85
83
86
84
r[cfg.options.crate]
87
-
It is not possible to set a
88
-
configuration option from within the source code of the crate being compiled.
85
+
It is not possible to set a configuration option from within the source code of the crate being compiled.
89
86
90
87
> [!NOTE]
91
88
> For `rustc`, arbitrary-set configuration options are set using the [`--cfg`] flag. Configuration values for a specified target can be displayed with `rustc --print cfg --target $TARGET`.
@@ -97,9 +94,7 @@ r[cfg.target_arch]
97
94
### `target_arch`
98
95
99
96
r[cfg.target_arch.gen]
100
-
Key-value option set once with the target's CPU architecture. The value is
101
-
similar to the first element of the platform's target triple, but not
102
-
identical.
97
+
Key-value option set once with the target's CPU architecture. The value is similar to the first element of the platform's target triple, but not identical.
103
98
104
99
r[cfg.target_arch.values]
105
100
Example values:
@@ -116,8 +111,7 @@ r[cfg.target_feature]
116
111
### `target_feature`
117
112
118
113
r[cfg.target_feature.general]
119
-
Key-value option set for each platform feature available for the current
120
-
compilation target.
114
+
Key-value option set for each platform feature available for the current compilation target.
121
115
122
116
r[cfg.target_feature.values]
123
117
Example values:
@@ -130,19 +124,16 @@ Example values:
130
124
*`"sse2"`
131
125
*`"sse4.1"`
132
126
133
-
See the [`target_feature` attribute] for more details on the available
134
-
features.
127
+
See the [`target_feature` attribute] for more details on the available features.
135
128
136
129
r[cfg.target_feature.crt_static]
137
-
An additional feature of `crt-static` is available to the
138
-
`target_feature` option to indicate that a [static C runtime] is available.
130
+
An additional feature of `crt-static` is available to the `target_feature` option to indicate that a [static C runtime] is available.
139
131
140
132
r[cfg.target_os]
141
133
### `target_os`
142
134
143
135
r[cfg.target_os.general]
144
-
Key-value option set once with the target's operating system. This value is
145
-
similar to the second and third element of the platform's target triple.
136
+
Key-value option set once with the target's operating system. This value is similar to the second and third element of the platform's target triple.
146
137
147
138
r[cfg.target_os.values]
148
139
Example values:
@@ -162,9 +153,7 @@ r[cfg.target_family]
162
153
### `target_family`
163
154
164
155
r[cfg.target_family.general]
165
-
Key-value option providing a more generic description of a target, such as the family of the
166
-
operating systems or architectures that the target generally falls into. Any number of
167
-
`target_family` key-value pairs can be set.
156
+
Key-value option providing a more generic description of a target, such as the family of the operating systems or architectures that the target generally falls into. Any number of `target_family` key-value pairs can be set.
168
157
169
158
r[cfg.target_family.values]
170
159
Example values:
@@ -186,13 +175,7 @@ r[cfg.target_env]
186
175
### `target_env`
187
176
188
177
r[cfg.target_env.general]
189
-
Key-value option set with further disambiguating information about the target
190
-
platform with information about the ABI or `libc` used. For historical reasons,
191
-
this value is only defined as not the empty-string when actually needed for
192
-
disambiguation. Thus, for example, on many GNU platforms, this value will be
193
-
empty. This value is similar to the fourth element of the platform's target
194
-
triple. One difference is that embedded ABIs such as `gnueabihf` will simply
195
-
define `target_env` as `"gnu"`.
178
+
Key-value option set with further disambiguating information about the target platform with information about the ABI or `libc` used. For historical reasons, this value is only defined as not the empty-string when actually needed for disambiguation. Thus, for example, on many GNU platforms, this value will be empty. This value is similar to the fourth element of the platform's target triple. One difference is that embedded ABIs such as `gnueabihf` will simply define `target_env` as `"gnu"`.
196
179
197
180
r[cfg.target_env.values]
198
181
Example values:
@@ -209,13 +192,10 @@ r[cfg.target_abi]
209
192
### `target_abi`
210
193
211
194
r[cfg.target_abi.general]
212
-
Key-value option set to further disambiguate the target with information about
213
-
the target ABI.
195
+
Key-value option set to further disambiguate the target with information about the target ABI.
214
196
215
197
r[cfg.target_abi.disambiguation]
216
-
For historical reasons, this value is only defined as not the empty-string when actually
217
-
needed for disambiguation. Thus, for example, on many GNU platforms, this value will be
218
-
empty.
198
+
For historical reasons, this value is only defined as not the empty-string when actually needed for disambiguation. Thus, for example, on many GNU platforms, this value will be empty.
219
199
220
200
r[cfg.target_abi.values]
221
201
Example values:
@@ -228,8 +208,7 @@ Example values:
228
208
r[cfg.target_endian]
229
209
### `target_endian`
230
210
231
-
Key-value option set once with either a value of "little" or "big" depending
232
-
on the endianness of the target's CPU.
211
+
Key-value option set once with either a value of "little" or "big" depending on the endianness of the target's CPU.
233
212
234
213
r[cfg.target_pointer_width]
235
214
### `target_pointer_width`
@@ -262,12 +241,10 @@ r[cfg.target_has_atomic]
262
241
### `target_has_atomic`
263
242
264
243
r[cfg.target_has_atomic.general]
265
-
Key-value option set for each bit width that the target supports
266
-
atomic loads, stores, and compare-and-swap operations.
244
+
Key-value option set for each bit width that the target supports atomic loads, stores, and compare-and-swap operations.
267
245
268
246
r[cfg.target_has_atomic.stdlib]
269
-
When this cfg is present, all of the stable [`core::sync::atomic`] APIs are available for
270
-
the relevant atomic width.
247
+
When this cfg is present, all of the stable [`core::sync::atomic`] APIs are available for the relevant atomic width.
271
248
272
249
r[cfg.target_has_atomic.values]
273
250
Possible values:
@@ -282,22 +259,17 @@ Possible values:
282
259
r[cfg.test]
283
260
### `test`
284
261
285
-
Enabled when compiling the test harness. Done with `rustc` by using the
286
-
[`--test`] flag. See [Testing] for more on testing support.
262
+
Enabled when compiling the test harness. Done with `rustc` by using the [`--test`] flag. See [Testing] for more on testing support.
287
263
288
264
r[cfg.debug_assertions]
289
265
### `debug_assertions`
290
266
291
-
Enabled by default when compiling without optimizations.
292
-
This can be used to enable extra debugging code in development but not in
293
-
production. For example, it controls the behavior of the standard library's
294
-
[`debug_assert!`] macro.
267
+
Enabled by default when compiling without optimizations. This can be used to enable extra debugging code in development but not in production. For example, it controls the behavior of the standard library's [`debug_assert!`] macro.
295
268
296
269
r[cfg.proc_macro]
297
270
### `proc_macro`
298
271
299
-
Set when the crate being compiled is being compiled with the `proc_macro`
300
-
[crate type].
272
+
Set when the crate being compiled is being compiled with the `proc_macro`[crate type].
301
273
302
274
r[cfg.panic]
303
275
### `panic`
@@ -448,9 +420,7 @@ Zero, one, or more attributes may be listed. Multiple attributes will each be ex
448
420
r[cfg.macro]
449
421
### The `cfg` macro
450
422
451
-
The built-in `cfg` macro takes in a single configuration predicate and evaluates
452
-
to the `true` literal when the predicate is true and the `false` literal when
453
-
it is false.
423
+
The built-in `cfg` macro takes in a single configuration predicate and evaluates to the `true` literal when the predicate is true and the `false` literal when it is false.
0 commit comments