Skip to content

#[cfg_attr] #1242

Closed
Closed
@DylanLukes

Description

@DylanLukes

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

For example:

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

On OS X this expands to

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

On Linux is expands to

#[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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-frontendArea: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions