graydon/rust — Issue #1242: #[cfg_attr]
Author: DylanLukes
Created: 2011-12-01 14:05:58+00:00
State: open

#[cfg_attr] is a theoretical tag for conditional use of an attribute based on target.

For example:

```rust
#[cfg_attr(target_os="macos", foo, bar(a, b), ...)]
#[cfg_attr(target_os="linux", baz(c, d), qux, ...)]
```

On OS X this expands to

```rust
#[foo]
#[bar(a,b)]
```

On Linux is expands to

```rust
#[baz(c,d)]
#[bar]
```

This would probably be eventually replaced by a more powerful meta-item system. I'm thinking along the lines of cmake?