LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 763|回复: 3

帮忙看看如何编译的问题

[复制链接]
发表于 2005-3-15 15:52:22 | 显示全部楼层 |阅读模式
这是一段没有写完的源代码,不过应该能编译的。
[PHP]#include <stdio.h>
#include <regexp.h>

int main(int args, char *argv[])
{
        regex_t compiled_reg;
        char str0[20], ebuffer[256];
        int z, cflag = 0;
        char *pattern = "";
        z = regcomp(&compiled_reg, pattern, cflag);
        if (z != 0) {
                regerror(z, &compiled_reg, ebuffer, sizeof(ebuffer));
                fprintf(stderr, "%s: pattern '%s'\n", ebuffer, pattern);
                exit(1);
        }
}
[/PHP]

运行如下命令进行编译时出错。
cc regexp.c -o regexp
In file included from regexp.c:2:
/usr/include/regexp.h: In function `compile':
/usr/include/regexp.h:115: error: `INIT' undeclared (first use in this function)
/usr/include/regexp.h:115: error: (Each undeclared identifier is reported only once
/usr/include/regexp.h:115: error: for each function it appears in.)
/usr/include/regexp.h:115: error: parse error before "regex_t"
/usr/include/regexp.h:129: error: `__expr_ptr' undeclared (first use in this function)

用cc regexp.c -o regexp -lc 也不行
各位高手帮忙看看吧
发表于 2005-3-15 17:38:32 | 显示全部楼层
感觉是少了某个头文件
回复 支持 反对

使用道具 举报

发表于 2005-3-15 20:25:33 | 显示全部楼层
加上: #include <sys/types.h>

#include <regex.h>改成#include <regex.h>
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-16 16:13:07 | 显示全部楼层
多谢k501,问题解决了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表