linux c下怎样查找定义?

changy 2007-09-06 04:04:15
请问在linux下怎样查找c标准库定义的一些结构体和宏的定义呢?
比如说结构体time_t,宏va_list的定义怎样可以查到?

是否有什么方法或者工具
...全文
887 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
plusboy 2007-09-10
  • 打赏
  • 举报
回复
man + ctags
find /usr/include/ -name "*.h" | xargs grep va_list
roadtang 2007-09-10
  • 打赏
  • 举报
回复

我一直用的是比较笨的方法. (难道是上瘾了?? :p )
IDE就是用emacs.
nickshen_qidian 2007-09-10
  • 打赏
  • 举报
回复
www.baidu.com或者www.google.cn
jun_yang5i5j 2007-09-09
  • 打赏
  • 举报
回复
man
manrenmanren 2007-09-08
  • 打赏
  • 举报
回复
先找到相应的头文件 一般在include目录下
然后查找相关的文件
changy 2007-09-07
  • 打赏
  • 举报
回复
呵呵,roadtang的方法好麻烦

综上,我想有两个较好的选择,vim+cscope,eclipse+CDT.
不知道大家在linux下都用什么来开发c,c++软件的呢?
是上面那两种吗?还是其它的?
貌似emacs也不错,就是用起来比较麻烦

希望大家给我个建议,谢谢
qld001 2007-09-07
  • 打赏
  • 举报
回复
嘿嘿,我在linux下用eclipse+CDT作编辑器的,可以按住Ctrl然后鼠标点击要查询的字段,会直接跳转到包含该字段定义的文件中,并且直接停在定义的位置上,很方便的~~
roadtang 2007-09-07
  • 打赏
  • 举报
回复
这个不容易查, 最好你本来就是知道 某个struct在哪个头文件里.
(比如 struct time_t 在 time.h), 这部分查C Standard.pdf最好.

用grep 示例.
$ grep -lr "time_t" /usr/include/
/usr/include/asm/shmbuf.h
/usr/include/asm/sembuf.h
/usr/include/asm/msgbuf.h
/usr/include/asm/posix_types.h
/usr/include/time.h
/usr/include/sys/select.h
/usr/include/sys/time.h
...... <-- 此处省略 N百行.

要得到所有包含 time_t的文件,
而按C标准中, /usr/include/time.h是正确的.

可是真正的实现又复杂点, Linux glibc里,time.h里又没有struct time_t这样的定义.
而是
typedef __time_t time_t;

而__time_t又是在另外一个/usr/include/bits/types.h头文件里定义的.


真正的位置不太容易用一个命令就得到的,
用grep找出一组文件, 或者 从标准的头文件顺藤摸瓜去找是一个可行的办法.
星羽 2007-09-07
  • 打赏
  • 举报
回复
man -
changy 2007-09-07
  • 打赏
  • 举报
回复
多谢大家.
我装的fc7,man可以查到函数的用法和说明,但查不到该函数的位置,也就是看不到函数的定义
至于c的宏和结构体名,类型名,用man的话得到的是Not found
请问grep怎么查呢? 比如说time_t,麻烦哪位给个示例.谢谢
cceczjxy 2007-09-07
  • 打赏
  • 举报
回复
grep
wangxs_1984 2007-09-07
  • 打赏
  • 举报
回复
看相应的.h文件啊!
jixingzhong 2007-09-07
  • 打赏
  • 举报
回复
grep
gfxiang 2007-09-07
  • 打赏
  • 举报
回复
如果连上网的话,还可以用google搜索,很方便的
下面这个网站比较不错
http://www.cplusplus.com/
每次搜函数、结构的定义原型、使用等,只有在google输入要查的函数名、结构名,再加上cplusplus就可以找到这个网站上的内容,比如搜time_t
就输入关键字
time_t cplusplus
搜va_list,输入
va_list cplusplus
gfxiang 2007-09-07
  • 打赏
  • 举报
回复
如果系统里安装了c的manual,可以用man命令查询各种函数、宏等
如果没有装,那只有到头文件目录下grep搜索啦
goodluckyxl 2007-09-06
  • 打赏
  • 举报
回复
man -
飞哥 2007-09-06
  • 打赏
  • 举报
回复
只能用grep命令查找
没有啥好办法
飞哥 2007-09-06
  • 打赏
  • 举报
回复
Linux C常用类型定义



typedef struct _IO_FILE FILE;
typedef struct st_list LIST;
typedef struct st_mem_root MEM_ROOT;
typedef struct st_mysql MYSQL;
typedef struct st_mysql_bind MYSQL_BIND;
typedef struct st_mysql_data MYSQL_DATA;
typedef struct st_mysql_field MYSQL_FIELD;
typedef struct st_mysql_res MYSQL_RES;
typedef char ** MYSQL_ROW;
typedef struct st_mysql_rows MYSQL_ROWS;
typedef struct st_mysql_stmt MYSQL_STMT;
typedef struct st_net NET;
typedef struct st_used_mem USED_MEM;
typedef struct st_vio Vio;
struct _IO_FILE;
struct _IO_FILE;
typedef void _IO_lock_t;
struct _IO_marker;
struct _IO_marker;
typedef long int __blkcnt_t;
typedef long int __blksize_t;
typedef long long unsigned int __dev_t;
typedef long int __fd_mask;
typedef unsigned int __gid_t;
typedef long unsigned int __ino_t;
typedef unsigned int __mode_t;
typedef unsigned int __nlink_t;
typedef long long int __off64_t;
typedef long int __off_t;
typedef long long int __quad_t;
typedef long int __suseconds_t;
typedef long int __time_t;
typedef long long unsigned int __u_quad_t;
typedef unsigned int __uid_t;
typedef char;
typedef char;
struct cns_mysql_struct;
typedef double;
typedef double;
enum enum_field_types;
enum enum_mysql_stmt_state;
enum enum_mysql_stmt_state;
enum enum_server_command;
typedef struct {
__fd_mask __fds_bits[32];
} fd_set;
typedef char * gptr;
struct hostent;
struct in_addr;
typedef unsigned int in_addr_t;
typedef short unsigned int in_port_t;
typedef int;
typedef long int;
typedef long int;
typedef long long int;
typedef long long unsigned int;
typedef long unsigned int;
typedef unsigned int mode_t;
typedef char my_bool;
typedef int my_socket;
typedef long long unsigned int my_ulonglong;
enum mysql_option;
enum mysql_status;
struct re_pattern_buffer;
typedef long unsigned int reg_syntax_t;
typedef struct re_pattern_buffer regex_t;
typedef struct {
regoff_t rm_so;
regoff_t rm_eo;
} regmatch_t;
typedef int regoff_t;
typedef short unsigned int sa_family_t;
typedef short int;
typedef short unsigned int;
typedef signed char;
typedef unsigned int size_t;
struct sockaddr_in;
struct st_list;
struct st_mem_root;
struct st_mysql;
struct st_mysql_bind;
struct st_mysql_bind;
struct st_mysql_data;
struct st_mysql_field;
struct st_mysql_methods;
struct st_mysql_methods;
struct st_mysql_options;
struct st_mysql_res;
struct st_mysql_res;
struct st_mysql_rows;
struct st_mysql_stmt;
struct st_mysql_stmt;
struct st_net;
struct st_used_mem;
struct stat;
typedef long int time_t;
struct timespec;
struct timeval;
struct tm;
typedef short unsigned int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned char;
typedef unsigned int;
typedef unsigned int;
typedef unsigned int;


飞哥 2007-09-06
  • 打赏
  • 举报
回复
time_t就是一个long
xugang_2001 2007-09-06
  • 打赏
  • 举报
回复
不知道楼主用的是什么系统,我用的是Ubuntu,用man命令就可以了,比如 man va_list 就可以列出定义信息了
加载更多回复(1)

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧