我正在将我的旧代码库移植到VS 2015。
这段代码是:
#if XYZ
....
#elif CLOCKS_PER_SEC > 999 //<< Getting error here.
...
#endif
我在CLOCKS_PER_SEC
这一行遇到了错误:
Severity Code Description
Error C1012 unmatched parenthesis: missing ')'
查看在time.h
头文件中CLOCKS_PER_SEC
的定义
// The number of clock ticks per second
#define CLOCKS_PER_SEC ((clock_t)1000)
看起来是因为预处理器宏无法与 clock_t
一起使用。
请建议我如何修复?
c:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt\time.h
是time.h
文件的名称。 - Ashish NegiCLOCKS_PER_SEC
以其他方式定义并不奇怪。没有人承诺它将永远定义为(1000)
。事实上,(1000)
是无效的定义。语言规范要求它具有clock_t
类型,而不是int
类型。 - AnT stands with RussiaCLOCKS_PER_SEC
的问题与 C99 标准中的缺陷有关,而不是 MSVC 编译器中的某些问题。原始的 C99 标准在定义CLOCKS_PER_SEC
时存在缺陷。这个缺陷在后来的一个 TC 中得到了修复。 - AnT stands with Russia