【发布时间】:2011-01-19 14:37:54
【问题描述】:
我正在将代码从 VS2005 移植到 C++ Builder XE,以便它可以与两个编译器一起编译。以下代码在 VS2005 下编译良好,但在 C++ Builder 下,我收到带有内联函数 rawtime(); 的主题错误消息;
(E2321 声明未指定标签或标识符)。
代码如下:
template<typename counter_type>
class synchronizer
{
private:
// PRIVATE TYPES
typedef timer<counter_type> timer_type;
typedef reference_point<counter_type> reference_point_type;
typedef time_data<counter_type> time_data;
typedef typename timer_type::time_stamp_type time_stamp_type;
typedef typename timer_type::time_span_type time_span_type;
typedef typename filetime_counter::value_type time_type;
typedef typename counter_type::value_type counter_value_type;
typedef synchronizer<counter_type> this_type;
/* some code removed for sake of this post */
public:
typedef counter_type counter_type;
typedef typename counter_type::value_type raw_value_type;
TIMESTATS_STMT(typedef statistics<counter_type> statistics_type);
inline raw_value_type rawtime() const /* Subject ERROR coming from this line */
{
return m_timer.now().value();
}
我尝试遵循这篇文章的结果,它解决了这个特定问题,但没有解决这个问题。 template class operator overloading problem
想法/通讯?
--- 编辑:
建议 TIMESTATS_STMT 是错误的真正原因的反馈,所以这里是如何定义的。注意 TIME_ENABLE_STATISTICS 在 VS2005 和 C++ Builder XE 中都被注释掉了。
// #define TIME_ENABLE_STATISTICS
//
//
// Make null definitions
//
#define TIMESTATS_VAR(var, type, initial)
#define TIMESTATS_STMT(stmt)
#ifdef TIME_ENABLE_STATISTICS
//
// Make real definitions
//
#undef TIMESTATS_VAR
#define TIMESTATS_VAR(var, type, initial) type var = initial
#undef TIMESTATS_STMT
#define TIMESTATS_STMT(stmt) stmt
--- 编辑
违规行似乎是 TIMESTATS_STMT 行。我可以通过取消定义 NULL #define 来纠正,如下所示。
#ifdef TIME_ENABLE_STATISTICS
TIMESTATS_STMT(typedef statistics<counter_type> statistics_type);
#endif
【问题讨论】:
标签: c++ function inline declaration