聘我网

新概念招聘3.0

如何查处某个宏定义在哪个头文件内?

vote up0vote downstar
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <linux/user.h>   /* For constants
                                   ORIG_EAX etc */
int main()
{   pid_t child;
    long orig_eax;
    child = fork();
    if(child == 0) {
        ptrace(PTRACE_TRACEME, 0, NULL, NULL);
        execl("/bin/ls", "ls", NULL);
    }
    else {
        wait(NULL);
        orig_eax = ptrace(PTRACE_PEEKUSER,
                          child, 4 * ORIG_EAX,
                          NULL);
        printf("The child made a "
               "system call %ld\n", orig_eax);
        ptrace(PTRACE_CONT, child, NULL, NULL);
    }
    return 0;
}

编译报错:

‘ORIG_EAX’ undeclared (first use in this function)

碰到诸如此类的问题,我该如何查找到底某个宏在哪个头里?

 

2 个答复

vote up0vote downcheck
[sproat@ test]# find /usr/include/ -name *.h | xargs grep 'ORIG_EAX' 
/usr/include/sys/reg.h:# define ORIG_EAX 11
/usr/include/asm/ptrace-abi.h:#define ORIG_EAX 11
链接
vote up0vote down

Very valid, pithy, scucinct, and on point. WD.

链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.