# Include "clucene. H" after a rather long search for the cause strigi crash on PPC (e.g.

Source: Internet
Author: User
Common clucene Problems

After a rather long search for the cause strigi crash on PPC (e.g. mac Mini), I found out that it is a good idea to always use the flag-ANSI when compiling C ++ code.

What happened?

Strigi uses clucene as an index backend. by default it is compiled without-ANSI. strigi has-ANSI as a default flag. this causes a problem when using the math. h header. this file,/usr/lib/GCC/PowerPC-Linux-GNU/4.1.2/include/bits/mathdef. h, defines the type float_t differently depending on the-ANSI flag.

 
# Ifdef _ gnuc __# if defined (_ strict_ansi _) typedef float float_t; typedef double double_t; # elsetypedef double float_t; typedef double double_t; typedef double double_t; # endif

Putting such macro magic in public header files is madness and can cause nasty bugs. For example, you can have a class like this:

 
Class planet {float_t mass ;};

If you new allocate this class with 'new planet () 'you allocate either 4, 8 or 16 bytes depending on your flags and architecture. If this class is
In a library, and you compile the code that uses the library with different flags than the ones with which you compiled the library, weird things
Will happen. Since your objects are smaller or bigger than you shall CT you will start writing in the wrong memory positions when working with
Objects.

I just spent quite some time tracking down a bug like this and thought it worthwhile to tell you about it so you are aware of this issue and can
Hopefully fix it faster then I did when you encounter it.

How do I use the multi field search?
# Include "clucene. H "# include" clucene/util/reader. H "# include <iostream> # include <conio. h> using namespace Lucene: Index; using namespace Lucene: Analysis; using namespace Lucene: util; using namespace Lucene: store; using namespace Lucene: document; using namespace Lucene: search; using namespace Lucene: queryparser; # include "clucene/queryparser/multifieldqueryparser. H "Void searchmultifields (char_t * dir, Const char_t * qry, const char_t ** fields, const int fieldslen) {l_byte_t * flags = new l_byte_t [fieldslen]; for (INT I = 0; I <fieldslen; I ++) flags [I] = Lucene: queryparser: multifieldqueryparser: normal_field; Standard: standardanalyzer analyzer; query & Q = multifieldqueryparser: parse (qry, fields, fieldslen, flags, analyzer); indexreader & reader = indexreader: open (DIR); indexsearcher searcher (Reader); hi TS & hits = searcher. search (Q); const char_t toks [] = {','}; For (INT I = 0; I 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.