Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

cfg_target_object_format

The tracking issue for this feature is: #152586


The cfg_target_object_format feature makes it possible to execute different code depending on the current target’s object file format.

Examples

#![allow(unused)]
#![feature(cfg_target_object_format)]

fn main() {
#[cfg(target_object_format = "elf")]
fn a() {
    // ...
}

#[cfg(target_object_format = "mach-o")]
fn a() {
    // ...
}

fn b() {
    if cfg!(target_object_format = "wasm") {
        // ...
    } else {
        // ...
    }
}
}