#include <iostream>
#include <string>
#include "tinyxml.h"
#include "tinystr.h"
void dump_to_stdout(const char* pFilename)
{
TiXmlDocument doc(pFilename);
bool loadOkay = doc.LoadFile();
if(!loadOkay)
{
printf("\n%s:\n", pFilename);
dump_to_stdout( &doc ); // defined later in the tutorial
}
else
{
printf("Failed to load file \"%s\"\n", pFilename);
}
}
int main(void)
{
dump_to_stdout("example1.xml");
return 0;
}
编译连接出现这样的错误:
error C2664: 'dump_to_stdout' : cannot convert parameter 1 from 'class TiXmlDocument *' to 'const char *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
这是为什么啊?这个都是从tinyxml开源上拷下来的!

解决方案 »

  1.   

    .....,把#include "stdafx.h"加入你的tinyxml文件下面,然后你要看看你的程序选择的是char*的方式还是string的方式设置预编译器
      

  2.   

    不好意思啊!这个stdafx.h头文件系统里没有啊!我从其网上其他地方下载了个到项目目录下// stdafx.h : include file for standard system include files,
    //  or project specific include files that are used frequently, but
    //      are changed infrequently
    //#if !defined(AFX_STDAFX_H__4607A810_33E2_483D_80D8_BE41F0D473D5__INCLUDED_)
    #define AFX_STDAFX_H__4607A810_33E2_483D_80D8_BE41F0D473D5__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    // Insert your headers here
    #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
    #define DLLEXPORT __declspec(dllexport)
    #define DLLIMPORT __declspec(dllimport)#include "stdio.h"
    #include <windows.h>
    #include <winsock2.h>
    #include <ws2tcpip.h>#pragma comment(lib,"ws2_32.lib")// TODO: reference additional headers your program requires here
    void Msg(char *szFormat, ...);
    void dbMsg(char *szFormat, ...);
    //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_STDAFX_H__4607A810_33E2_483D_80D8_BE41F0D473D5__INCLUDED_)
    不知道是怎么设置预编译器是char * 还是string