上述代码有没有这种编译错误main.cc:7:21: error: ‘int time [1000][1000]’ redeclared as different kind of symbol int time[1000][1000]={0}; //每个距离节点花的总时间 ^ In file included from /usr/include/pthread.h:24, from /usr/include/c++/8/x86_64-redhat-linux/bits/gthr-default.h:35, from /usr/include/c++/8/x86_64-redhat-linux/bits/gthr.h:148, from /usr/include/c++/8/ext/atomicity.h:35, from /usr/include/c++/8/bits/ios_base.h:39, from /usr/include/c++/8/ios:42, from /usr/include/c++/8/ostream:38, from /usr/include/c++/8/iostream:39, from main.cc:1: /usr/include/time.h:75:15: note: previous declaration ‘time_t time(time_t*)’ extern time_t time (time_t *__timer) __THROW; ^~~~ main.cc: In function ‘int main()’: main.cc:20:11: warning: pointer to a function used in arithmetic [-Wpointer-arith] time[i][j] =0; ^ main.cc:20:14: warning: pointer ...
时间: 2024-01-12 15:04:55 浏览: 102
keil MDK编译器警告和错误详解
5星 · 资源好评率100%
这个编译错误的原因是在你的代码中,定义了一个名为 `time` 的二维数组,而 C++ 标准库中也有一个名为 `time` 的函数,这导致了命名冲突。
为了解决这个问题,你可以考虑修改数组的名称,例如将 `time` 改为 `my_time` 或者其他不与已有函数或变量重名的名称。另外,编译器给出的警告信息可能是因为你在使用指针时出了一些问题,你需要仔细检查代码并修复这些问题。
阅读全文