Switch to use builtin bitflags! macro

* use builtin bitflags implementation
* fix compile error of demo code