Move common macros into a new crate (fixes #1882)