红联Linux门户
Linux帮助

gcc编译问题

发布时间:2011-06-15 18:19:30来源:红联作者:smallQ_nj
这段代码是我从网上找的,功能是获取当前进程的掩码,它通过capget函数来获取指定进程的能力掩码,也可以用capset来设定掩码。但我根据论文上说的来调试,通过gcc,没有成功,报出了蛮多错误的。

#undef _POSIX_SOURCE
#include
#include
#include
#include
#include
#include
int main()
{
struct __user_cap_header_struct cap_header_data;
cap_user_header_t cap_header = &cap_header_data;
struct __user_cap_data_struct cap_data_data;
cap_user_data_t cap_data = &cap_data_data;
cap_header->pid = getpid();
cap_header->version = _LINUX_CAPABILITY_VERSION_1;
if (capget(cap_header, cap_data) < 0) {
perror("Failed capget");
exit(1);
}
printf("Cap data 0x%x, 0x%x, 0x%x\n", cap_data->effective,
cap_data->permitted, cap_data->inheritable);
}

错误是
[root@localhost ]# gcc -g new.c -o new
new.c: In function ‘main’:
new.c:11:1: error: stray ‘\302’ in program
new.c:11:1: error: stray ‘\240’ in program
new.c:11:1: error: stray ‘\302’ in program
new.c:11:1: error: stray ‘\240’ in program
new.c:11:1: error: stray ‘\302’ in program
.......
(the same error from line 11 to the end)
what's error about 302 & 240 ??

这边从第11行开始到最后都是这样的错误。
不知道这里的240和302各是什么样的错误。

求解呀!
文章评论

共有 3 条评论

  1. lgcHR 于 2011-06-28 10:49:04发表:

    有奇怪的字符程序中,楼主细察之

  2. smallQ_nj 于 2011-06-16 00:30:32发表:

    2# 奶茶dsk


    明天去试试哈~谢谢啦

  3. 奶茶dsk 于 2011-06-15 19:18:00发表:

    第11行一列是不是有啥看不见的字符,删除之