Question

I have a quite simple code in C++, here it is:

namespace Phoenix
{
    template<typename T>
    struct Ref
    {
    private: T* _instance;
    public: inline Ref(T* instance) { ... }
    public: inline Ref(const Ref<T> &reference) { ... }
    public: inline Ref<T>& operator=(const Ref<T> &reference) { ... }
    };
}

This code is in a Visual 2012 C++ Library.

Now, if I try to reuse it in a final application, a C2894 error occurs saying I cannot declare a template to have a 'C' linkage. OK.

I didn't use extern 'C'...

Any idea ? Am I missing something ?

Was it helpful?

Solution

Thanks to Roger Rowland, I fixed the bug in my solution.

I named a file "String.h" which uses my template struct Ref.

Since it exists another file named <string.h> by default in my project (from the C++ STL), the compiler took this one instead of mine and so the bug came.

A simple rename of the first one solved the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top