I can deal with porting platform dependent functions. I have a problem that the compilers I tried on Linux (clang and g++) do not accept the following code, while the msvc++ compiler does:

template <class T>
class Base {
    T Value;

template <class T>
class Derived : public Base<T> {
    void setValue(const T& inValue){
        Value = inValue;

int main(int argc, char const *argv[])
    Derived<int> tmp;
    return 0;

g++ error:

main.cpp: In member function ‘void Derived<T>::setValue(const T&)’:
main.cpp:11:3: error: ‘Value’ was not declared in this scope

I believe this due to the use of a non-dependent name (Value) in the second class. More information.

The problem is that I have a very large code base, in which this type of code is used very often. I understand that it is wrong when looking at the standard. However it is very convenient not having to write this-> or Base<T>:: in front of every use of Value. Even writing using Base<T>::Value; at the start of the derived class is problematic when you use ~20 members of the base class.

So my question is: are there compilers for Linux that allow this kind of code (with or without extra compiler switches)? Or are there small modifications that will allow this code to compile on Linux?

  • 2
    The only sensible modification is to fix the broken code; even if some compiler does support this, it's a bug and could be fixed at any time.
    – Useless
    Commented Oct 30, 2012 at 14:58
  • 2
    Actually, even if you have such a construct several hundred times in your code, fixing it should not take you more than a few hours using a decent text editor, since the compiler tells you exactly where you have to change your code.
    – Doc Brown
    Commented Oct 30, 2012 at 17:27

1 Answer 1


I also posted this question on SO. From the few comments here and the answers there I reach the same conclusion: I have to fix my code. Adding my own answer so I can mark this question as accepted/resolved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.