红联Linux门户
Linux帮助

linux下查找变量与常量的头文件方法

发布时间:2007-07-26 16:49:50来源:红联作者:atulations
今天看别人写的程序,遇到函数,常量找不到头文件的错误,在windows中好解决,在linux下看书看到了,所以摘下来供以后察看

摘自:Beginning.Linux.Programming,Third.Edition

It’s often convenient to use the grep command to search header files for particular definitions and function
prototypes. Suppose we need to know the name of the #defines used for returning the exit status
from a program. Simply change to the /usr/include directory and grep for a probable part of the
name like this:
$ grep EXIT_ *.h
...
stdlib.h:#define EXIT_FAILURE 1 /* Failing exit status. */
stdlib.h:#define EXIT_SUCCESS 0 /* Successful exit status. */
...
$
Here grep searches all the files in the directory with a name ending in .h for the string EXIT_. In this
example, it has found (among others) the definition we need in the file stdlib.h.
文章评论

共有 0 条评论