3

I'm trying to use Xapian library in my Qt-project. I've just added header:

#include <QtCore/QCoreApplication>
#include <xapian.h>

using namespace std;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);   

    return a.exec();
} 

And there are already some mistakes here:

/usr/local/include/xapian/keymaker.h:64: error: a template-id may not appear in 
a using-declaration
64: std::vector<std::pair<Xapian::valueno, bool> > slots;

and this one as well:

/usr/local/include/xapian/keymaker.h:77: error: expected primary-expression 
before ‘.’ token
77: slots.push_back(std::make_pair(slot, reverse));

I don't know what does it mean. But I guess I should add something into my pro-file. Could you please help me? Thanks.

sobr_vamp
  • 45
  • 4

1 Answers1

4

The problem you run into is that Xapian uses "slots" as identifier, but "slots" is also a define in Qt:

From qobjectdefs.h

# if defined(QT_NO_KEYWORDS)
#  define QT_NO_EMIT
# else
#   define slots
#   define signals protected
# endif

As you include QApplication (and thus qobjectdefs.h) before xapian.h, the preprocessor deletes all occurrences of "slots" from xapian.h. To avoid this problem, build your project with -DQT_NO_KEYWORDS. You then have to use "Q_SLOTS" and "Q_SIGNALS" instead of "signals" and "slots" in your Qt Code (which is good practice anyway).

Frank Osterfeld
  • 24,815
  • 5
  • 58
  • 70
  • Thanks. Your solution is much better than mine. I've just replaced "slots" to "slots1" in keymaker.h. Maybe later I'll use your suggestion. – sobr_vamp Jun 19 '11 at 13:37