ANTLR C 目标和 XMLLib
我有一个用 C 编写的程序,它使用 XMLLib 和从 ANTLR 生成的词法分析器/解析器。
我的包含看起来像:
#include "MyParser.h"
#include "MyLexer.h"
#include "antlr3.h"
#include <libxml/tree.h>
#include <libxml/parser.h>
问题是我的程序拒绝编译,错误如下:
In file included from /usr/include/libxml2/libxml/parser.h:19:0,
from /usr/include/libxml2/libxml/globals.h:18,
from /usr/include/libxml2/libxml/threads.h:35,
from /usr/include/libxml2/libxml/xmlmemory.h:218,
from /usr/include/libxml2/libxml/tree.h:1248,
from MyProgram.c:4:
/usr/include/libxml2/libxml/valid.h:276:21: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
/usr/include/libxml2/libxml/valid.h:302:21: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
In file included from /usr/include/libxml2/libxml/globals.h:18:0,
from /usr/include/libxml2/libxml/threads.h:35,
from /usr/include/libxml2/libxml/xmlmemory.h:218,
from /usr/include/libxml2/libxml/tree.h:1248,
from MyProgram.c:4:
/usr/include/libxml2/libxml/parser.h:800:19: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
In file included from /usr/include/libxml2/libxml/parser.h:808:0,
from /usr/include/libxml2/libxml/globals.h:18,
from /usr/include/libxml2/libxml/threads.h:35,
from /usr/include/libxml2/libxml/xmlmemory.h:218,
from /usr/include/libxml2/libxml/tree.h:1248,
from MyProgram.c:4:
/usr/include/libxml2/libxml/xmlIO.h:293:19: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
In file included from /usr/include/libxml2/libxml/globals.h:18:0,
from /usr/include/libxml2/libxml/threads.h:35,
from /usr/include/libxml2/libxml/xmlmemory.h:218,
from /usr/include/libxml2/libxml/tree.h:1248,
from MyProgram.c:4:
/usr/include/libxml2/libxml/parser.h:961:22: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
/usr/include/libxml2/libxml/parser.h:967:22: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
/usr/include/libxml2/libxml/parser.h:1063:54: error: expected ‘)’ before ‘f’
/usr/include/libxml2/libxml/parser.h:1065:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘xmlGetExternalEntityLoader’
/usr/include/libxml2/libxml/parser.h:1068:19: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
如果我不包含前两个包含,则所有内容都会正确编译(我用简单的“return 0”替换了我的 main() 函数)。知道是什么原因造成的吗? :(
我的编译命令如下所示:
gcc *.c -c -lantlr3c -I/usr/include/libxml2
编辑:我从 Ubuntu 包管理器安装了 libxml2-dev 包(如果这有影响的话)
I have a program written in C which uses XMLLib and a lexer/parser generated from ANTLR.
My includes look like:
#include "MyParser.h"
#include "MyLexer.h"
#include "antlr3.h"
#include <libxml/tree.h>
#include <libxml/parser.h>
The problem is my program refuses to compile, erroring with:
In file included from /usr/include/libxml2/libxml/parser.h:19:0,
from /usr/include/libxml2/libxml/globals.h:18,
from /usr/include/libxml2/libxml/threads.h:35,
from /usr/include/libxml2/libxml/xmlmemory.h:218,
from /usr/include/libxml2/libxml/tree.h:1248,
from MyProgram.c:4:
/usr/include/libxml2/libxml/valid.h:276:21: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
/usr/include/libxml2/libxml/valid.h:302:21: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
In file included from /usr/include/libxml2/libxml/globals.h:18:0,
from /usr/include/libxml2/libxml/threads.h:35,
from /usr/include/libxml2/libxml/xmlmemory.h:218,
from /usr/include/libxml2/libxml/tree.h:1248,
from MyProgram.c:4:
/usr/include/libxml2/libxml/parser.h:800:19: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
In file included from /usr/include/libxml2/libxml/parser.h:808:0,
from /usr/include/libxml2/libxml/globals.h:18,
from /usr/include/libxml2/libxml/threads.h:35,
from /usr/include/libxml2/libxml/xmlmemory.h:218,
from /usr/include/libxml2/libxml/tree.h:1248,
from MyProgram.c:4:
/usr/include/libxml2/libxml/xmlIO.h:293:19: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
In file included from /usr/include/libxml2/libxml/globals.h:18:0,
from /usr/include/libxml2/libxml/threads.h:35,
from /usr/include/libxml2/libxml/xmlmemory.h:218,
from /usr/include/libxml2/libxml/tree.h:1248,
from MyProgram.c:4:
/usr/include/libxml2/libxml/parser.h:961:22: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
/usr/include/libxml2/libxml/parser.h:967:22: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
/usr/include/libxml2/libxml/parser.h:1063:54: error: expected ‘)’ before ‘f’
/usr/include/libxml2/libxml/parser.h:1065:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘xmlGetExternalEntityLoader’
/usr/include/libxml2/libxml/parser.h:1068:19: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
If I don't include the first two includes everything compiles correctly (I replaced my main() function with a simple 'return 0'). Any idea what could be causing this? :(
My compile command looks like:
gcc *.c -c -lantlr3c -I/usr/include/libxml2
Edit: I installed libxml2-dev package from the Ubuntu package manager if this makes a difference
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来有些宏观问题。 parser.h 的第 961 行包含 ID,它可能在您的标头之一中定义。
Looks like some macro problems. Line 961 of parser.h includes ID, which may be defined in one of your headers.
我不确定是否可以复活这个主题,但是即使我尝试使用“-I /usr/include/libxml2”,对于一个更简单的程序我也遇到了同样的问题。但是,一旦我也传递了链接参数,代码就能够编译。
Libxml.org 当前的常见问题解答 (http://www.xmlsoft.org/FAQ.html )谈论这个:
不确定一年前是否已经有了这个有用的提示。
I'm not sure if its ok to resurrect the topic, but I was having the same problem for a more simple program even if I tried to use the "-I /usr/include/libxml2". However, once I passed the linked argument too the code was able to compile.
The current FAQ of Libxml.org (http://www.xmlsoft.org/FAQ.html )talk about this:
Not sure if one year ago was already with this useful tip.