为什么这里将end定义为main里变量正常,而定义为全局变量报错?

使用c++测试ctime模块,发现将 clock_t start, end; 放在 main 中没问题,但是放在全局变量中出错,是什么原因?

# include <iostream>
# include <ctime>

using namespace std;
clock_t start, end;

int main(){
    int ans = 0, times=1e8;

    start = clock();
    for (int i=0; i<times; i++){
        ans ++;
    }
    end = clock();
    double endtime = (double)(end-start) / CLOCKS_PER_SEC;

    cout << "Total time: " << endtime << endl;    

    return 0;
}

img

因为C++中有不少跟end同名的函数
建议改一下变量名