报错代码(A.hh文件里的):
namespace TooN {namespace Internal
{template<class Precision> struct DefaultTypes
{
typedef Precision* PointerType;
typedef const Precision* ConstPointerType;
typedef Precision& ReferenceType;
typedef const Precision& ConstReferenceType;
};
template<int Size, class Precision, bool heap> class StackOrHeap;template<int Size, class Precision> class StackOrHeap<Size,Precision,0>
{
public:
StackOrHeap()
{
debug_initialize(my_data, Size);
}
Precision my_data[Size];
};template<int Size> class StackOrHeap<Size,double,0>
{
public:
StackOrHeap()
{
debug_initialize(my_data, Size);!!!!!!!!!!!!这里提示Use of undeclared identifier 'debug_initialize'
}
double my_data[Size] TOON_ALIGN8 ;
};
debug_initialize函数定义在B.hh文件里,如下:
namespace TooN {namespace Internal
{ #if defined  TOON_CHECK_BOUNDS  || defined TOON_TEST_INTERNALS
static inline void check_index(int s, int i)
{
if(i<0 || i >= s)
{
#ifdef TOON_TEST_INTERNALS
throw Internal::BadIndex();
#else
std::cerr << "Toon index out of range" << std::endl;
std::abort();
#endif
}
}
#else
///@internal
///Function used to check bounds.
///By default it does nothing. See \ref sDebug.
static inline void check_index(int, int){}
#endif #if defined TOON_INITIALIZE_SNAN
template<class P> static void debug_initialize(P* data, int n)
{
using std::numeric_limits;
for(int i=0; i < n; i++)
data[i] = numeric_limits<P>::signaling_NaN();
}
#elif defined TOON_INITIALIZE_QNAN || defined TOON_INITIALIZE_NAN
template<class P> static void debug_initialize(P* data, int n)
{
using std::numeric_limits;
for(int i=0; i < n; i++)
data[i] = numeric_limits<P>::quiet_NaN();
}
#elif defined TOON_INITIALIZE_VAL
template<class P> static void debug_initialize(P* data, int n)
{
for(int i=0; i < n; i++)
data[i] = TOON_INITIALIZE_VAL;
}
#elif defined TOON_INITIALIZE_RANDOM
union intbits
{
unsigned long i;
char c[4];
};
两个文件定义的namespace是一样的,为什么提示debug_initialize没有声明啊,这个代码是从别的平台移植过来的,在windows下是不会报错的。xCode平台为什么会报这个错误呢?请xCode大虾赐教~~

解决方案 »

  1.   


    A.hh中添加:
    #include "B.hh"
      

  2.   

    或者在预处理文件XXX.pch中添加
    #import "B.hh"
      

  3.   


    你再看下代码,,,debug_initialize这个函数只是在存在某些宏的情况下才存在的。#if defined TOON_INITIALIZE_SNAN
    template<class P> static void debug_initialize(P* data, int n)
    {
    using std::numeric_limits;
    for(int i=0; i < n; i++)
    data[i] = numeric_limits<P>::signaling_NaN();
    }
    #elif defined TOON_INITIALIZE_QNAN || defined TOON_INITIALIZE_NAN
    template<class P> static void debug_initialize(P* data, int n)
    {
    using std::numeric_limits;
    for(int i=0; i < n; i++)
    data[i] = numeric_limits<P>::quiet_NaN();
    }
    #elif defined TOON_INITIALIZE_VAL
    template<class P> static void debug_initialize(P* data, int n)
    {
    for(int i=0; i < n; i++)
    data[i] = TOON_INITIALIZE_VAL;
    }
    #elif defined TOON_INITIALIZE_RANDOM
    union intbits
    {
    unsigned long i;
    char c[4];
    };如果那些宏不存在,编译的时候就会找不到该函数。