0

Criei um cabeçalho com as definições da dll:

globaldef.h

#pragma once

#ifdef OPENXML_LIB
#define OPENXML __declspec(dllexport)
#else
#define OPENXML __declspec(dllimport)
#endif // OPENXML_LIB

Criei duas classes até o momento:

xmldoc.h

#pragma once

#define XML_MODE_R 0
#define XML_MODE_RW 1

#include "globaldef.h"
#include <fstream>
#include <string>

class OPENXML XmlDocumment {

public:

    XmlDocumment(std::string fileName, int mode);
    ~XmlDocumment();

    //Load xml content to string
    virtual std::string read();

private:

    //Xml file
    std::fstream xmlFile;
    std::string filename;
    int mode = 0;

};

xmldoc.cpp

#include "stdafx.h" 
#include "xmldoc.h" 
XmlDocumment::XmlDocumment(std::string fileName, int mode) { 
     this->filename = fileName; 
     this->mode = mode; 
} 
XmlDocumment::~XmlDocumment() { } 
std::string XmlDocumment::read() { 
     switch (mode) { 
         case XML_MODE_R: xmlFile.open(filename, std::ios::in); break; 
         case XML_MODE_RW: break; 
     } 
std::string content((std::istreambuf_iterator<char>(xmlFile)), (std::istreambuf_iterator<char>())); 
xmlFile.close(); 
return content; 

}

E a outra classe no momento não comecei a escrever

xmlnode.h

#pragma once

#include "globaldef.h"

class OPENXML XmlNode {

public:


};

Tudo compila normalmente se não houver um construtor, porém se adiciono um construtor mesmo sem parâmetros algum ou vazio, o compilador emite o seguinte error:

inserir a descrição da imagem aqui

4
  • Mostra o xmldoc.cpp
    – Sveen
    27/12/2017 às 13:35
  • #include "stdafx.h" #include "xmldoc.h" XmlDocumment::XmlDocumment(std::string fileName, int mode) { this->filename = fileName; this->mode = mode; } XmlDocumment::~XmlDocumment() { } std::string XmlDocumment::read() { switch (mode) { case XML_MODE_R: xmlFile.open(filename, std::ios::in); break; case XML_MODE_RW: break; } std::string content((std::istreambuf_iterator<char>(xmlFile)), (std::istreambuf_iterator<char>())); xmlFile.close(); return content; } 27/12/2017 às 17:46
  • Verifica se o nome das funções utilizadas no xmldoc estão correto, o visual studio de vez enquanto não avisa corretamente
    – Sveen
    28/12/2017 às 0:57
  • Verifica se o DLL não está corrompido
    – Sveen
    28/12/2017 às 0:59

0

Você deve fazer log-in para responder a esta pergunta.

Pesquise outras perguntas com a tag .