Qt project builds on Ubuntu but does not build on Windows

Asked

Viewed 106 times

1

I have a project for college originally produced on the linux platform using Qt Creator and I need to migrate it to windows. I tried to compile but the project has errors in a single header file and I don’t understand why .

Annex of part of the errors :

inserir a descrição da imagem aqui

Follows the class :

#ifndef PROPERTIES_H
#define PROPERTIES_H

#include <map>
#include <list>
#include <string>
#include <iostream>
#include <stdexcept>

class Properties
{
public:
    enum DataType
    {
        INT,
        VOID,
        FLOAT,
        BOOLEAN,
        STRING
    };

    struct Property
    {
        Property(const std::string& name_, Properties::DataType type_) :
            name(name_), type(type_) {}

        const std::string name;
        const Properties::DataType type;
    };

    Properties(){}
    Properties(const Properties& prop)
    {
        *this = prop;
    }
    ~Properties()
    {
        for(DataMap::iterator it = dataMap.begin(); it != dataMap.end(); ++it)
        {
            delete it->second;
        }
    }
    Properties& operator=(const Properties& prop)
    {
        for(DataMap::const_iterator it = prop.dataMap.begin(); it != prop.dataMap.end(); ++it)
            dataMap.insert(make_pair(it->first, it->second->getCopy()));

        return *this;
    }

    template<typename T>
    Properties& set(const std::string& name, const T& value)
    {
        DataMap::const_iterator it = dataMap.find(name);
        if(it != dataMap.end())
        {
            BaseDataRec *rec = it->second;
            if(rec->type == getType<T>())
                ((DataRec<T>*)rec)->data = value;
        }
        else
            dataMap.insert(make_pair(name, new DataRec<T>(value, getType<T>())));

        return *this;
    }

    bool has(const std::string& name) const
    {
        DataMap::const_iterator it = dataMap.find(name);
        if(it != dataMap.end())
            return true;

        return false;
    }

    template<typename T>
    bool has(const std::string& name) const
    {
        DataMap::const_iterator it = dataMap.find(name);
        if(it != dataMap.end())
        {
            if(it->second->type == getType<T>())
                return true;
        }

        return false;
    }

    template<typename T>
    T get(const std::string& name) const
    {
        DataMap::const_iterator it = dataMap.find(name);
        if(it != dataMap.end())
        {
            BaseDataRec *rec = it->second;
            if(rec->type == getType<T>())
                return ((DataRec<T>*)rec)->data;
            else
                std::cout << "\"" << name << "\" não é do tipo solicitado." << std::endl;
        }
        else
            std::cout << "\"" << name << "\" não encontrado." << std::endl;

        throw std::runtime_error("Erro ao obter o parametro.");
    }

    template<typename T>
    T get(const std::string& name, const T& def) const
    {
        DataMap::const_iterator it = dataMap.find(name);
        if(it != dataMap.end())
        {
            BaseDataRec *rec = it->second;
            if(rec->type == getType<T>())
                return ((DataRec<T>*)rec)->data;
            else
            {
                std::cout << "\"" << name << "\" não é do tipo solicitado." << std::endl;
                throw std::runtime_error("Erro ao obter o parametro.");
            }
        }

        return def;
    }

    std::list<Property> getSummary()
    {
        std::list<Property> result;
        for(DataMap::const_iterator it = dataMap.begin(); it != dataMap.end(); ++it)
            result.push_back(Property(it->first, it->second->type));
        return result;
    }

private:
    struct BaseDataRec
    {
        BaseDataRec(DataType t) :
            type(t)
        {}

        virtual BaseDataRec* getCopy() = 0;

        DataType type;
    };

    template<typename T>
    struct DataRec: public BaseDataRec
    {
        DataRec(const T& d, DataType t) :
            BaseDataRec(t), data(d)
        {}

        virtual DataRec<T>* getCopy()
        { return new DataRec<T>(data, type); }

        T data;
    };

    template<typename T>
    DataType getType() const
    {
        std::cout << "Não há suporte ao tipo solicitado." << std::endl; return VOID;
    }

    typedef std::map<std::string, BaseDataRec*> DataMap;
    DataMap dataMap;
};


#define SUPPORT_TYPE(type, enumtype) \
    template<> \
    inline Properties::DataType Properties::getType<type>() const \
    { return enumtype; }


SUPPORT_TYPE(int, Properties::INT)
SUPPORT_TYPE(float, Properties::FLOAT)
SUPPORT_TYPE(bool, Properties::BOOLEAN)
SUPPORT_TYPE(std::string, Properties::STRING)



#endif // PROPERTIES_H
  • You have already tested by changing the names of the enumeration values DataType? I’m not absolutely sure, but maybe in Windows there is already some definition of INT fully capitalized...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.