Scope of a #[cfg(...)]?

What entities do attributes such as #[cfg(windows)] operate on?

It's possible to put an if, else chain behind a #[cfg(...)], but not a let foo = ...;, but what's the exact rule?

The cfg attribute is allowed anywhere attributes are allowed.

Attributes may be applied to many things in the language:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.