#define
's are translation unit-local, but definitions are not. You need to put extern UIClass Platform;
in your header and UIClass Platform;
in an implementation file.
If you really want to have the definition in your header you can use some template class magic:
namespace detail {
// a template prevents multiple definitions
template<bool = true>
class def_once_platform {
static UIClass Platform;
};
// define instance
template<bool _> def_once_platform<_> def_once_platform<_>::Platform;
// force instantiation
template def_once_platform<> def_once_platform<>::Platform;
}
// get reference
UIClass& Platform = detail::def_once_platform<>::Platform;