Skip to content

Add cfg for crate_type? #45182

@joshlf

Description

@joshlf

I have some code that needs to be conditionally compiled only when the artifact that's being produced is a dynamic library, and the target platform is Mac (here's the code). Right now, I'm accomplishing that by providing a dylib feature that the crate's user is responsible for enabling if they're compiling a dynamic library.

This is ugly from a UX perspective, and introduces the possibility of bugs if the user fails to enable the feature when they should. It'd be better if there were a cfg setting that indicated the value of the crate_type so I could do this automatically without user help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamneeds-rfcThis change is large or controversial enough that it should have an RFC accepted before doing it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions