Неисправность сборки библиотеки RAPIDXML на компьютере - сообщения об ошибках

Я работаю над проектом C++, где я хотел бы использовать библиотеку rapidxml. Библиотеку можно найти здесь: http://rapidxml.sourceforge.net/ Я скачал это (4 файла с исходным кодом.hpp) и смог скомпилировать проект на моем компьютере с Windows с помощью IDE CodeBlocks.

Тем не менее, когда я попытался собрать это на машине Linux в школе, он показал следующие сообщения об ошибках и не скомпилируется успешно

Я не уверен, в чем проблема и как я могу избежать этих ошибок / предупреждений.

/mydirectory/rapidxml.hpp: In constructor 'rapidxml::parse_error::parse_error(const char*, void*)':
/mydirectory/rapidxml.hpp:78:13: error: declaration of 'where' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp:78:13: error: declaration of 'what' shadows a member of 'this' [-Werror=shadow]
In file included from /mydirectory/VmapXmlParser.h:10:0,
                 from /projectFolder/VmapXmlParser.cpp:1:
/mydirectory/rapidxml.hpp: In member function 'void rapidxml::xml_base<Ch>::name(const Ch*, std::size_t)':
/mydirectory/rapidxml.hpp:722:9: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'void rapidxml::xml_base<Ch>::name(const Ch*)':
/mydirectory/rapidxml.hpp:731:9: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'void rapidxml::xml_base<Ch>::value(const Ch*, std::size_t)':
/mydirectory/rapidxml.hpp:752:9: error: declaration of 'value' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'void rapidxml::xml_base<Ch>::value(const Ch*)':
/mydirectory/rapidxml.hpp:761:9: error: declaration of 'value' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In constructor 'rapidxml::xml_node<Ch>::xml_node(rapidxml::node_type)':
/mydirectory/rapidxml.hpp:902:13: error: declaration of 'type' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'void rapidxml::xml_node<Ch>::type(rapidxml::node_type)':
/mydirectory/rapidxml.hpp:1066:9: error: declaration of 'type' shadows a member of 'this' [-Werror=shadow]
In file included from /mydirectory/VmapXmlParser.h:11:0,
                 from /projectFolder/VmapXmlParser.cpp:1:
/mydirectory/rapidxml_utils.hpp: In constructor 'rapidxml::file<Ch>::file(const char*)':
/mydirectory/rapidxml_utils.hpp:40:20: error: declaration of 'size' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml_utils.hpp: In constructor 'rapidxml::file<Ch>::file(const char*) [with Ch = char]':
/projectFolder/VmapXmlParser.cpp:29:46:   instantiated from here
/mydirectory/rapidxml_utils.hpp:40:40: error: declaration of 'size' shadows a member of 'this' [-Werror=shadow]
In file included from /mydirectory/VmapXmlParser.h:10:0,
                 from /projectFolder/VmapXmlParser.cpp:1:
/mydirectory/rapidxml.hpp: In member function 'rapidxml::xml_node<Ch>* rapidxml::xml_node<Ch>::first_node(const Ch*, std::size_t, bool) const [with Ch = char, std::size_t = unsigned int]':
/projectFolder/VmapXmlParser.cpp:36:55:   instantiated from here
/mydirectory/rapidxml.hpp:936:23: error: declaration of 'name_size' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp:936:23: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'rapidxml::xml_node<Ch>* rapidxml::xml_node<Ch>::next_sibling(const Ch*, std::size_t, bool) const [with Ch = char, std::size_t = unsigned int]':
/projectFolder/VmapXmlParser.cpp:41:35:   instantiated from here
/mydirectory/rapidxml.hpp:1004:23: error: declaration of 'name_size' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp:1004:23: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'rapidxml::xml_attribute<Ch>* rapidxml::xml_node<Ch>::first_attribute(const Ch*, std::size_t, bool) const [with Ch = char, std::size_t = unsigned int]':
/projectFolder/VmapXmlParser.cpp:48:60:   instantiated from here
/mydirectory/rapidxml.hpp:1025:28: error: declaration of 'name_size' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp:1025:28: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'rapidxml::xml_attribute<Ch>* rapidxml::xml_attribute<Ch>::next_attribute(const Ch*, std::size_t, bool) const [with Ch = char, std::size_t = unsigned int]':
/projectFolder/VmapXmlParser.cpp:48:97:   instantiated from here
/mydirectory/rapidxml.hpp:856:28: error: declaration of 'name_size' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp:856:28: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In constructor 'rapidxml::xml_node<Ch>::xml_node(rapidxml::node_type) [with Ch = char]':
/mydirectory/rapidxml.hpp:1365:41:   instantiated from 'rapidxml::xml_document<Ch>::xml_document() [with Ch = char]'
/projectFolder/VmapXmlParser.cpp:30:30:   instantiated from here
/mydirectory/rapidxml.hpp:901:9: error: declaration of 'type' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]':
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:2114:17: error: switch missing default case [-Werror=switch-default]
/mydirectory/rapidxml.hpp: In member function 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_element(Ch*&) [with int Flags = 0, Ch = char]':
/mydirectory/rapidxml.hpp:2090:49:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:2043:24: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_pi(Ch*&) [with int Flags = 0, Ch = char]':
/mydirectory/rapidxml.hpp:2107:48:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:1889:28: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp:1899:29: error: declaration of 'value' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_comment(Ch*&) [with int Flags = 0, Ch = char]':
/mydirectory/rapidxml.hpp:2123:57:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:1790:25: error: declaration of 'value' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_cdata(Ch*&) [with int Flags = 0, Ch = char]':
/mydirectory/rapidxml.hpp:2134:55:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:2015:25: error: declaration of 'value' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_doctype(Ch*&) [with int Flags = 0, Ch = char]':
/mydirectory/rapidxml.hpp:2146:57:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:1817:25: error: declaration of 'value' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp:1834:25: error: switch missing default case [-Werror=switch-default]
/mydirectory/rapidxml.hpp: In member function 'void rapidxml::xml_base<Ch>::name(const Ch*, std::size_t) [with Ch = char, std::size_t = unsigned int]':
/mydirectory/rapidxml.hpp:2047:13:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_element(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:2090:49:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:721:14: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'void rapidxml::xml_document<Ch>::parse_node_attributes(Ch*&, rapidxml::xml_node<Ch>*) [with int Flags = 0, Ch = char]':
/mydirectory/rapidxml.hpp:2053:13:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_element(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:2090:49:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:2243:28: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp:2053:13:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_element(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:2090:49:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:2276:29: error: declaration of 'value' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'void rapidxml::xml_base<Ch>::value(const Ch*, std::size_t) [with Ch = char, std::size_t = unsigned int]':
/mydirectory/rapidxml.hpp:1910:17:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_pi(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:2107:48:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:751:14: error: declaration of 'value' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'void* rapidxml::memory_pool<Ch>::allocate_aligned(std::size_t) [with Ch = char, std::size_t = unsigned int]':
/mydirectory/rapidxml.hpp:419:65:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::memory_pool<Ch>::allocate_node(rapidxml::node_type, const Ch*, const Ch*, std::size_t, std::size_t) [with Ch = char, std::size_t = unsigned int]'
/mydirectory/rapidxml.hpp:2040:69:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_element(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:2090:49:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:618:69: error: cast from 'char*' to 'rapidxml::memory_pool<char>::header*' increases required alignment of target type [-Werror=cast-align]
/mydirectory/rapidxml.hpp: In member function 'void rapidxml::xml_base<Ch>::name(const Ch*) [with Ch = char]':
/mydirectory/rapidxml.hpp:426:21:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::memory_pool<Ch>::allocate_node(rapidxml::node_type, const Ch*, const Ch*, std::size_t, std::size_t) [with Ch = char, std::size_t = unsigned int]'
/mydirectory/rapidxml.hpp:2040:69:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_element(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:2090:49:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:730:14: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'void rapidxml::xml_base<Ch>::value(const Ch*) [with Ch = char]':
/mydirectory/rapidxml.hpp:433:21:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::memory_pool<Ch>::allocate_node(rapidxml::node_type, const Ch*, const Ch*, std::size_t, std::size_t) [with Ch = char, std::size_t = unsigned int]'
/mydirectory/rapidxml.hpp:2040:69:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_element(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:2090:49:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here
/mydirectory/rapidxml.hpp:760:14: error: declaration of 'value' shadows a member of 'this' [-Werror=shadow]
/mydirectory/rapidxml.hpp: In member function 'Ch rapidxml::xml_document<Ch>::parse_and_append_data(rapidxml::xml_node<Ch>*, Ch*&, Ch*) [with int Flags = 0, Ch = char]':
/mydirectory/rapidxml.hpp:2228:21:   instantiated from 'void rapidxml::xml_document<Ch>::parse_node_contents(Ch*&, rapidxml::xml_node<Ch>*) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:2059:17:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_element(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:2090:49:   instantiated from 'rapidxml::xml_node<Ch>* rapidxml::xml_document<Ch>::parse_node(Ch*&) [with int Flags = 0, Ch = char]'
/mydirectory/rapidxml.hpp:1404:68:   instantiated from 'void rapidxml::xml_document<Ch>::parse(Ch*) [with int Flags = 0, Ch = char]'
/projectFolder/VmapXmlParser.cpp:31:32:   instantiated from here

1 ответ

Решение

Вы используете GCC со строгими параметрами, которые превращают определенные (или, может быть, все) предупреждения в ошибки.

Пример - вот ошибки: -

rapidxml.hpp: In constructor 'rapidxml::parse_error::parse_error(const char*, void*)':
rapidxml.hpp:78:13: error: declaration of 'where' shadows a member of 'this'
[-Werror=shadow]
rapidxml.hpp:78:13: error: declaration of 'what' shadows a member of 'this'
[-Werror=shadow]

... и вот код

class parse_error: public std::exception
{
public:
    //! Constructs parse error
    parse_error(const char *what, void *where)
        : m_what(what)
        , m_where(where)
    {
    }

"Проблема" в том, что GCC считает, что код может быть неправильным, потому что what а также where используются в качестве имен параметров в конструкторе, но они также определяются как функции-члены базового класса. (std::exception).

Это совершенно правильно C++ и будет работать просто отлично. GCC просто настроен так, чтобы быть очень требовательным. Вам нужно будет добавить опцию -Wno-error=shadow чтобы эти предупреждения не обрабатывались как ошибки.

http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

Другие вопросы по тегам