Error: the global scope has no "clock"
Error: the global scope has no "clock"
我想在我的程序中使用 clock
函数,所以我指的是 how to use clock().
我的代码:
#include <iostream>
#include <cstdio>
#include <ctime>
int main() {
std::clock_t start;
//clock_t start;
double duration;
start = std::clock();
//start = clock(); //This Also not working
/* Your algorithm here */
duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
//duration = ( clock() - start ) / (double) CLOCKS_PER_SEC;
std::cout<<"printf: "<< duration <<'\n';
}
但我仍然遇到编译错误
error C2039: 'clock' : is not a member of '`global
namespace'' ....\ctime
error C2873: 'clock' : symbol cannot be used
in a using-declaration ....\ctime
error C3861: 'clock': identifier
not found ....\main.cpp
所以我通过在 visual studio 中打开也检查了 ctime
头文件
using _CSTD asctime; using _CSTD clock; using _CSTD ctime;
对于这一行,它给出了一个错误
Error: the global scope has no "clock"
请帮我解决这些错误?
我查看了我的程序包含路径。我已经看到 time.h
存在的两个位置。
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
替换了路径 C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
的 time.h
文件,该文件通过从另一个位置复制来引用我的程序。
我想在我的程序中使用 clock
函数,所以我指的是 how to use clock().
我的代码:
#include <iostream>
#include <cstdio>
#include <ctime>
int main() {
std::clock_t start;
//clock_t start;
double duration;
start = std::clock();
//start = clock(); //This Also not working
/* Your algorithm here */
duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
//duration = ( clock() - start ) / (double) CLOCKS_PER_SEC;
std::cout<<"printf: "<< duration <<'\n';
}
但我仍然遇到编译错误
error C2039: 'clock' : is not a member of '`global namespace'' ....\ctime
error C2873: 'clock' : symbol cannot be used in a using-declaration ....\ctime
error C3861: 'clock': identifier not found ....\main.cpp
所以我通过在 visual studio 中打开也检查了 ctime
头文件
using _CSTD asctime; using _CSTD clock; using _CSTD ctime;
对于这一行,它给出了一个错误
Error: the global scope has no "clock"
请帮我解决这些错误?
我查看了我的程序包含路径。我已经看到 time.h
存在的两个位置。
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
替换了路径 C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
的 time.h
文件,该文件通过从另一个位置复制来引用我的程序。