У меня есть программа, написанная на 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
Если я не включу первые два включения, все будет правильно компилироваться (я заменил функцию main() на простой «возврат 0»). Любая идея, что может быть причиной этого? :(
Моя команда компиляции выглядит так:
gcc *.c -c -lantlr3c -I/usr/include/libxml2
Изменить: я установил пакет libxml2-dev из диспетчера пакетов Ubuntu, если это имеет значение
-lxml2
компилятору. Я попробовал сгенерированный парсер на своей машине и, к сожалению, получил такие же ошибки. - person sidyll   schedule 21.07.2011