gcc 编译时候一个诡异的问题

2017-04-26 22:42:39 +08:00
 taozhijiangscu
如题,只是包含了一个简单的 iostream ,依赖到最后慢慢的包含了系统的 time.h ,导致无法编译通过

In file included from /usr/include/sched.h:34,
from /usr/include/pthread.h:25,
from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux/bits/gthr-default.h:41,
from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux/bits/gthr.h:162,
from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/atomicity.h:34,
from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/ios_base.h:41,
from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:43,
from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iostream:40,
from ../commonutil/Config.h:124,
from ../commonutil/ArgVector.h:4,
from ArgVector.cpp:1:
./time.h:27: 错误:‘ Int64 ’未声明
./time.h:28: 错误:‘ Int64 ’未声明
./time.h:29: 错误:‘ Int64 ’未声明
./time.h:30: 错误:‘ time_t ’未声明
./time.h:31: 错误:‘ time_t ’未声明
./time.h:33: 错误:‘ time_t ’未声明
./time.h:34: 错误:‘ time_t ’未声明

[user@centos6 test]$ find /usr -name time.h
/usr/include/linux/time.h
/usr/include/sys/time.h
/usr/include/bits/time.h
/usr/include/time.h
find: “/usr/lib64/audit ”: 权限不够
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/netfilter/xt/match/time.h
/usr/src/kernels/2.6.32-431.el6.x86_64/include/linux/time.h
/usr/src/kernels/2.6.32-431.el6.x86_64/arch/x86/include/asm/time.h
[user@centos6 test]$


日了狗了,有没有遇到过这种问题的?
2020 次点击
所在节点    C
8 条回复
arakashic
2017-04-27 05:14:30 +08:00
贴一下代码、编译方法和环境吧
copen
2017-04-27 14:17:44 +08:00
编译 c 还是 c++? 如果是 c++链接动态库了吗? -lstdc++
taozhijiangscu
2017-04-27 17:26:19 +08:00
@arakashic

公司的东西,贴出来不太方便吧

其实就是#include <iostream>,结果就搞到很多 C 头上面去了
arakashic
2017-04-27 22:50:50 +08:00
@taozhijiangscu 那这样,下面这个编译正常吗?
#include <iostream>

int main(int argc, char *argv[])
{
std::cout << "hw" << std::endl;
return 0;
}
我猜你代码的当前目录有一个 time.h 吧
taozhijiangscu
2017-04-28 18:25:22 +08:00
@arakashic

正常。项目中没有 time.h

唉,蛋疼……
cooldadiao
2017-05-05 17:26:49 +08:00
用 g++不是 gcc
taozhijiangscu
2017-05-06 08:23:53 +08:00
@cooldadiao

是 g++
pright
2017-05-09 22:30:25 +08:00
这个看起来就是引用了 ArgVector.cpp 所在目录下的 time.h,检查下项目的 makefile 里面对于头文件路径的设置。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/357580

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX