ошибка в одной строке программы Xerces - PullRequest
1 голос
/ 21 июня 2010

Следующее приложение выдает мне нарушение прав доступа в первой строке, что с этим?

// test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <xercesc/util/XMLString.hpp>

using namespace xercesc;

int main()
{

    XMLCh* path= XMLString::transcode("test.xml"); 

    return 0;
}

[править] Следующий код дает мне исключение в строке XMLFormatTarget, но если я изменяю строку с «C: /test.xml» на «test.xml», она работает нормально.

// test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/framework/LocalFileFormatTarget.hpp>

using namespace xercesc;

int main()
{
    XMLPlatformUtils::Initialize();

    XMLFormatTarget *formatTarget = new LocalFileFormatTarget("C:/test.xml"); 

    return 0;
}

1 Ответ

1 голос
/ 21 июня 2010

Очевидная ошибка в вашей программе заключается в том, что вы не инициализируете xerces-c перед его использованием.

http://xerces.apache.org/xerces-c/program-2.html

Вы должны вызвать XMLPlatformUtils::Initialize(), прежде чем делать любые другие вызовы xerces-с.

...