compilation fixes

No functionality changes.
- fix compilation warnings (gcc, clang)
- C++ "extern" wrapper
- usused variables cleanup