“not declared in this scope” error with templates and inheritance [duplicate]

myOption is not a dependent name, i.e. it doesn’t depend on the template arguments explicitly so the compiler tries to look it up early. You must make it a dependent name: template <typename InterfaceType> void ChildClass<InterfaceType>::set() { this->myOption = 10; } Now it depends on the type of this and thus on the template arguments. …

Read more

Linking to MSVC DLL from MinGW

You can’t do this. They have exported C++ classes from their dll, rather than C-functions. The difference is, c++ functions are always exported with names in a mangled form that is specific to a particular version of the compiler. Their dll is usable by msvc only in that form, and will probably not even work …

Read more

What’s the best g++ optimization level when building a debug target?

GCC 4.8 introduces a new optimization level: -Og for the best of both worlds. -Og Optimize debugging experience. -Og enables optimizations that do not interfere with debugging. It should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience. …

Read more

Why does alias template give a conflicting declaration?

The problem relies on SFINAE. If you rewrite your member function to be value_t<S<T>>, like the outside declaration, then GCC will happily compile it: template<class T> struct S { using value_type = int; static const value_t<S<T>> C = 0; }; template<class T> const value_t<S<T>> S<T>::C; Because the expression is now functionally equivalent. Things like substitution …

Read more

std::this_thread::sleep_for() and GCC

Confirmed that it doesn’t work here as well. (Recent GCC 4.6 snapshot). You could do the obvious and simply define it before you include any std:: headers. A bit dirty but will work until GCC fixes it (unless this is intended behavior). The #define shouldn’t break anything anyways. Either in source or -D_GLIBCXX_USE_NANOSLEEP flag to …

Read more