包含std字符串库时的qt creator问题

时间:2014-03-17 11:14:32

标签: c++ qt qt-creator stdstring

我有这个功能。我用libxml2和std :: string库创建了它。

#ifndef KNIHOVNA_H
#define KNIHOVNA_H
#include <string>
#include <libxml/tree.h>

std::string hledaniString(int index,xmlDocPtr sharedString)
{
std::string Istring;
xmlAttrPtr attr;

 xmlChar *attrValue;
    xmlNodePtr nodeLevel1 = sharedString->children;
int maxValue;
int aIndex;


attr = xmlHasProp(nodeLevel1, (const xmlChar*)"uniqueCount");
if (attr !=NULL)
    {
        attrValue = xmlGetProp(nodeLevel1, (xmlChar *)"uniqueCount");

    }
    else return "Chybny format souboru. Spatny soubor sharedStrings.xml.";

nodeLevel1 = nodeLevel1->children;

maxValue = atoi((const char *) attrValue);
xmlFree(attrValue);
if (maxValue<=index) return "Chybny format souboru. Spatny soubor sharedStrings.xml.";

for (aIndex = 0;aIndex < index; aIndex++ )
{
nodeLevel1 = nodeLevel1->next;
}
nodeLevel1 = nodeLevel1->children;
attrValue = xmlNodeGetContent(nodeLevel1);
xmlFree(attrValue);
attrValue = xmlNodeGetContent(nodeLevel1);
Istring = (char *) attrValue;
xmlFree(attrValue);
    return Istring;

#endif // KNIHOVNA_H

我在Code Block项目中使用它,一切正常,在qt creator项目中,我得到了这些错误:

/usr/include/c++/4.8/string:38: In file included from /usr/include/c++/4.8/string:38:0,
/usr/include/c++/4.8/bits/stl_relops.h:-1: In function 'std::string getString(int, xmlDocPtr)':
/usr/include/c++/4.8/bits/stl_relops.h:67: error: expected '=' before '__attribute__'
/usr/include/c++/4.8/bits/stl_relops.h:67: error: expected identifier before '__attribute__'
/usr/include/c++/4.8/bits/stl_relops.h:67: error: expected ';' before '__attribute__'
/usr/include/c++/4.8/bits/stl_relops.h:67: error: expected primary-expression before '__attribute__'
/usr/include/c++/4.8/bits/stl_relops.h:67: error: expected ';' before '__attribute__'
/home/daffy/qt projektz/revize/main.cpp:15: error: expected '}' at end of input

有人能帮帮我吗?

0 个答案:

没有答案