Is there a list of all cfg functions?

Rust has the ability to verify the configuration during assembly using, for example, #[cfg(target_os = "linux")]or if cfg!(target_os = "linux") {...}, where is a target_osfunction.

Is there a list of all (or at least commonly used) functions that can be tested in Rust?


See related question on attributes. Is there an exhaustive list of standard attributes anywhere? .

+4
source share
2 answers

In the "Conditional Compilation" section of the link there is a list of configurations that must be defined (starting with Rust 1.14):

  • target_arch with values:
    • x86
    • x86_64
    • mips
    • powerpc
    • powerpc64
    • arm
    • aarch64
  • target_os with values ​​such as:
    • windows
    • macos
    • ios
    • linux
    • android
    • freebsd
    • dragonfly
    • bitrig
    • openbsd
    • netbsd
  • target_family with values ​​such as:
    • unix
    • windows
  • unix(shortcut to target_family)
  • windows(shortcut to target_family)
  • target_env with values ​​such as:
    • gnu
    • msvc
    • musl
    • "" ( )
  • target_endian :
    • little
    • big
  • target_pointer_width , :
    • 32
    • 64
  • target_has_atomic :
    • 8
    • 16
    • 32
    • 64
    • ptr
  • target_vendor , :
    • apple
    • pc
    • unknown
  • test
  • debug_assertions
+9

Source: https://habr.com/ru/post/1667257/


All Articles