Posts Tagged ‘MSVC’

MSVC Trickiness: CRTP Dependencies

Monday, September 2nd, 2024

I got complacent developing my game on a Mac and Linux boxes so far, and have neglected to actually compile my game on Windows, even though I from the start did intend Windows as a first-class deployment target. I’ve finally gotten around to it, and to no surprise, it’s not been particularly smooth. But some of the problems have been surprising to me.

One I had not previously encountered is this: One portion of my game uses a CRTP (Curiously Recurring Template Pattern) base, that abstracts away some repetitive bits that several derived types need. It looked something like this:

struct Meta {
    const char *stuff;
};

template <typename Derived>
struct Helper {
    static constexpr Meta kMeta = { Derived::kStuff };
};

struct Foo : Helper<Foo> {
    static constexpr const char *kStuff = "stuff";
};

This works fine on GCC, Clang, and ICC. But MSVC?

error C2039: 'kStuff': is not a member of 'Derived'

No way!

(more…)