Skip to content

k3dsdk/property_collection.cpp is missing #include <algorithm> #42

@lychaxo

Description

@lychaxo

On my system (gcc 9.3.0 on Linux with glibc 2.30), compilation of both latest master (commit 17ef1bf) and the latest release 0.8.0.6 fails with an attempt to cast k3d::iproperty to const char * in k3dsdk/property_collection.cpp -- because GCC isn't seeing std::remove from and is instead finding the closest match of int remove(const char *) from stdio.h which is placed in the std namespace when #include'd via g++.

/tmp/SBo/k3d-k3d-0.8.0.6/k3dsdk/property_collection.cpp: In member function ‘virtual void k3d::property_collection::register_property(k3d::iproperty&)’:
/tmp/SBo/k3d-k3d-0.8.0.6/k3dsdk/property_collection.cpp:50:51: error: cannot convert ‘std::vector<k3d::iproperty*>::iterator’ {aka ‘__gnu_cxx::__normal_iterator<k3d::iproperty**, std::vector<k3d::iproperty*> >’} to ‘const char*’
   50 |  m_properties.erase(std::remove(m_properties.begin(), m_properties.end(), &Property), m_properties.end());
      |                                 ~~~~~~~~~~~~~~~~~~^~
      |                                                   |
      |                                                   std::vector<k3d::iproperty*>::iterator {aka __gnu_cxx::__normal_iterator<k3d::iproperty**, std::vector<k3d::iproperty*> >}
In file included from /usr/include/c++/9.3.0/cstdio:42,
                 from /usr/include/c++/9.3.0/ext/string_conversions.h:43,
                 from /usr/include/c++/9.3.0/bits/basic_string.h:6493,
                 from /usr/include/c++/9.3.0/string:55,
                 from /usr/include/c++/9.3.0/stdexcept:39,
                 from /usr/include/c++/9.3.0/array:39,
                 from /usr/include/c++/9.3.0/tuple:39,
                 from /usr/include/c++/9.3.0/functional:54,
                 from /usr/include/sigc++-2.0/sigc++/reference_wrapper.h:22,
                 from /usr/include/sigc++-2.0/sigc++/adaptors/bound_argument.h:24,
                 from /usr/include/sigc++-2.0/sigc++/adaptors/bind.h:6,
                 from /usr/include/sigc++-2.0/sigc++/adaptors/adaptors.h:23,
                 from /usr/include/sigc++-2.0/sigc++/sigc++.h:107,
                 from /tmp/SBo/k3d-k3d-0.8.0.6/k3dsdk/signal_system.h:23,
                 from /tmp/SBo/k3d-k3d-0.8.0.6/k3dsdk/iproperty.h:28,
                 from /tmp/SBo/k3d-k3d-0.8.0.6/k3dsdk/property_collection.cpp:24:
/usr/include/stdio.h:146:32: note:   initializing argument 1 of ‘int remove(const char*)’
  146 | extern int remove (const char *__filename) __THROW;
      |                    ~~~~~~~~~~~~^~~~~~~~~~

According to https://en.cppreference.com/w/cpp/algorithm/remove, #include needs to be added. Adding it fixes the compilation of this file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions