【发布时间】:2014-12-20 12:53:26
【问题描述】:
我正在尝试让最初用 C 编写的软件在 Visual C++ 中编译。这是我到目前为止的代码:
#include "timer.h"
FILE * timerFP = stdout;
int timerCount = 0;
double time_Master = 0.0;
static tsc_type tsc_Master;
void Timer_Start(void)
{
readTSC(tsc_Master);
}
void Timer_Stop(void)
{
tsc_type tsc_Master2;
readTSC(tsc_Master2);
time_Master += diffTSC(tsc_Master,tsc_Master2);
}
但是 Visual C++ 给了我以下错误:
error C2099: initializer is not a constant.
我该如何解决这个问题?谢谢你。
【问题讨论】:
-
指向的完整错误信息(包括行号和类似信息)是什么?
-
很确定是这一行:
FILE * timerFP = stdout; -
它指向'FILE * timerFP = stdout;'行
-
将标签从 [C++] 更改为 [C]。代码在 [C++] 中工作,即使它是无效的 [C]
-
变量 timerFP 没有被使用,所以你可以去掉那一行。 stdout 直到运行时才设置,因此它的内容直到运行时才知道。
标签: c