#plugin #macro

nightly fourcc

Syntax extension to generate FourCCs (four-character code)

4 releases

Uses old Rust 2015

0.0.4 Sep 18, 2015
0.0.3 Mar 25, 2015
0.0.2 Nov 21, 2014
0.0.1 Nov 20, 2014

#1857 in Procedural macros


99 lines


A Rust syntax extension to generate FourCCs.

Build Status


Add this to your Cargo.toml:


fourcc = "*"

and this to your crate root:



Syntax extension to generate FourCCs.

Once loaded, fourcc!() is called with a single 4-character string, and an optional ident that is either big, little, or target. The ident represents endianness, and specifies in which direction the characters should be read. If the ident is omitted, it is assumed to be big, i.e. left-to-right order. It returns a u32.


To load the extension and use it:

extern crate fourcc;

fn main() {
    let val = fourcc!("\xC0\xFF\xEE!");
    assert_eq!(val, 0xC0FFEE21u32);
    let little_val = fourcc!("foo ", little);
    assert_eq!(little_val, 0x21EEFFC0u32);


No runtime deps