At first I am apologize for a slightly longer code... There are 3 classes A,B,C
A.h
#ifndef A_H
#define A_H
template <typename T>
class C;
class A
{
public:
template <typename T>
static void testa ( T b);
};
#include "A.hpp"
#endif
A.hpp
#ifndef A_HPP
#define A_HPP
#include "C.h"
#include "B.h"
template <typename T>
void A::testa ( T a)
{
B::testb( a );
}
#endif
B.h
#ifndef B_H
#define B_H
class B
{
public:
template <typename T>
static void testb ( T b );
};
#include "B.hpp"
#endif
B.hpp
#ifndef B_HPP
#define B_HPP
#include "C.h"
template <typename T>
void B::testb ( T b )
{
C <T>::test(b, e1 ); //Error
}
#endif
C.h
#ifndef C_H
#define C_H
#include "A.h"
typedef enum
{
e1=1, e2,
} TEnum;
template <typename T>
class C
{
public:
static void test (T c, const TEnum t) {}
};
#endif
main.cpp
#include "A.h"
using namespace std;
int main()
{
double x = 1.0;
A::testa(x);
return 0;
}
Due to the possible circular dependency (my estimation), when the code is a part of the library, the following eeror occurs:
C <T>::test(b, e1 ); |261|error: 'e1' was not declared in this scope|.
However, extracting the code to the example, the error can not be reproduced.
The VS2012 compiler works well in both cases...
I do not, how to fix such a type of the problem? Is it a good way to use extern?
It is clear that it is difficult to advise; especially, when the error can not be reproduced...
Thanks for your help...