add mcon
add extern "C" to support C++