Visual c++ .inl文件c++;

Visual c++ .inl文件c++;,visual-c++,Visual C++,在.inl文件(visual c++)中实现函数模板时遇到问题 我有一个头文件 数学.h->> #ifndef _MATH_H #define _MATH_H #include <math.h> template<class REAL=float> struct Math { // inside this structure , there are a lot of functions , for example this.. static REAL

在.inl文件(visual c++)中实现函数模板时遇到问题

我有一个头文件

数学.h->>

#ifndef _MATH_H
#define _MATH_H
#include <math.h>

template<class REAL=float>
struct Math
{
     // inside this structure , there are a lot of functions , for example this..
     static REAL  sin ( REAL __x );
     static REAL  abs ( REAL __x );
};

#include "implementation.inl"     // include inl file
#endif
\ifndef\u数学
#定义数学
#包括
模板
结构数学
{
//在这个结构中,有很多函数,例如。。
静态实正弦(实x);
静态真实abs(真实x);
};
#包括“implementation.inl”//include inl文件
#恩迪夫
这是.inl文件

implementation.inl-->

模板
真实数学::sin(真实)
{
返回(实际)sin((双)ux);
}
模板
真实数学::abs(真实)
{
如果(uux<(实)0)
返回-uux;
返回x;
}
当我调用正弦函数时,它在运行时抛出一个错误。但是,abs功能可以工作 没错

我认为问题在于调用.inl文件中的math.h头函数之一


为什么我不能在.inl文件中使用math.h函数?

这个问题与
.inl
文件无关-您只需递归调用
math::sin()
,直到堆栈溢出。在MSVC 10中,我甚至得到一个很好的警告,指出:

warning C4717: 'Math<double>::sin' : recursive on all control paths, function will cause runtime stack overflow
另外,作为旁注:宏名
\u MATH\u H
保留供编译器实现使用。在许多使用实现保留标识符的情况下,您可能会有点不幸运地实际遇到冲突(尽管您仍然应该避免使用此类名称)。但是,在这种情况下,该名称很有可能与
math.h
可能实际用于防止自身被多次包含的名称冲突


你绝对应该选择一个不太可能冲突的名字。有关规则,请参阅。

您是否要求我们推测您看到的错误?
warning C4717: 'Math<double>::sin' : recursive on all control paths, function will cause runtime stack overflow
 return (REAL) ::sin ( (double) __x ); // note the `::` operator