Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spurious "duplicate declaration" error with class members #406

Open
pitrou opened this issue Dec 11, 2018 · 13 comments
Open

Spurious "duplicate declaration" error with class members #406

pitrou opened this issue Dec 11, 2018 · 13 comments
Labels
bug Problem in existing code code Source code

Comments

@pitrou
Copy link

pitrou commented Dec 11, 2018

For one (and only one) of the classes in my project, I get a "duplicate declaration error" than I cannot explain:

Warning, treated as error:
/home/antoine/arrow/docs/source/cpp/api/builder.rst:31:Duplicate declaration.
Makefile:71: recipe for target 'html' failed
make: *** [html] Error 2

The directive is as follows:

.. doxygenclass:: arrow::BooleanBuilder
   :members:

If I remove the :members: flag, the error isn't emitted. How do I discover which member exactly is causing the duplicate declaration error, and why?

@vermeeren vermeeren self-assigned this Dec 11, 2018
@vermeeren
Copy link
Collaborator

Could you check if your specific case is the same as #356? Perhaps parts of #405 (and linked issues from there) are also relevant.

If your issue is not related to the above I probably need more information.

@vermeeren vermeeren added the support Not actual issues, but help label Dec 11, 2018
@pitrou
Copy link
Author

pitrou commented Dec 11, 2018

None of those two issues seem related. I'll try to see if I can single out the offending declaration (it would be nice if breathe said exactly what is duplicated).

@pitrou
Copy link
Author

pitrou commented Dec 11, 2018

Ok, the two conflicting method declarations are the following (I'm omitting the implementations):

  /// \brief Append a sequence of elements in one shot, with a specified nullmap
  /// \param[in] values_begin InputIterator to the beginning of the values
  /// \param[in] values_end InputIterator pointing to the end of the values
  /// \param[in] valid_begin InputIterator with elements indication valid(1)
  ///  or null(0) values
  /// \return Status
  template <typename ValuesIter, typename ValidIter>
  typename std::enable_if<!std::is_pointer<ValidIter>::value, Status>::type AppendValues(
      ValuesIter values_begin, ValuesIter values_end, ValidIter valid_begin) {
     ...
  }

  /// \brief Append a sequence of elements in one shot, with a specified nullmap
  /// \param[in] values_begin InputIterator to the beginning of the values
  /// \param[in] values_end InputIterator pointing to the end of the values
  /// \param[in] valid_begin uint8_t* indication valid(1) or null(0) values.
  ///  nullptr indicates all values are valid.
  /// \return Status
  template <typename ValuesIter, typename ValidIter>
  typename std::enable_if<std::is_pointer<ValidIter>::value, Status>::type AppendValues(
      ValuesIter values_begin, ValuesIter values_end, ValidIter valid_begin) {
     ...
  }

This is the same template method implemented differently, depending on parameter type, using SFINAE.

@jakobandersen
Copy link
Collaborator

I'm quite sure this particular problem is a missing check in Sphinx. Please open an issue over there with a pointer to this issue, then I'll get around to it at some point.

@pitrou
Copy link
Author

pitrou commented Dec 11, 2018

Ok, I opened sphinx-doc/sphinx#5755 in Sphinx.

@pitrou
Copy link
Author

pitrou commented Dec 11, 2018

Note this is easily circumvented by removing one of the docstrings... Still, it is highly not obvious how to diagnose the issue and find the workaround.

@jakobandersen
Copy link
Collaborator

Thanks. I'll try to get the warning message improved as well (i.e., changing line https://github.com/sphinx-doc/sphinx/blob/master/sphinx/domains/cpp.py#L6459)

@vermeeren vermeeren removed the support Not actual issues, but help label Dec 11, 2018
@pitrou
Copy link
Author

pitrou commented Jan 23, 2019

I've got another case where I get a "duplicate declaration" with doxygen 1.8.14 (but not 1.8.13). It boils down to:

class BasicDecimal128 {
 public:
  /// \brief Create a BasicDecimal128 from the two's complement representation.
  constexpr BasicDecimal128(int64_t high, uint64_t low) noexcept
      : low_bits_(low), high_bits_(high) {}

  /// \brief Empty constructor creates a BasicDecimal128 with a value of 0.
  constexpr BasicDecimal128() noexcept : BasicDecimal128(0, 0) {}

 private:
  uint64_t low_bits_;
  int64_t high_bits_;
};

class Decimal128 : public BasicDecimal128 {
 public:
  using BasicDecimal128::BasicDecimal128;

  /// \brief Empty constructor wrapper over BasicDecimal128. This is required on some
  /// older compilers.
  constexpr Decimal128() noexcept : BasicDecimal128() {}
};

Together with:

.. doxygenclass:: arrow::Decimal128
   :project: arrow_cpp
   :members:

I get:

Warning, treated as error:
/home/antoine/arrow/docs/source/cpp/api/utilities.rst:25:Duplicate declaration, constexpr arrow::BasicDecimal128::BasicDecimal128()

This is with breathe 4.11.1 and sphinx 1.8.4+/d58f1018.

@pitrou
Copy link
Author

pitrou commented Jan 23, 2019

Note it would also be nice to disable those "duplicate definition" warnings. There seem to be too many quirks with Doxygen-generated symbols.

@jakobandersen
Copy link
Collaborator

I think the new problem may be in the same family as #356.

@pitrou
Copy link
Author

pitrou commented Jan 23, 2019

Not sure. I am not documenting the base class here (not in Sphinx, I mean). Also I have INLINE_INHERITED_MEMB = NO in the Doxyfile.

@vermeeren vermeeren removed their assignment Feb 8, 2019
@vermeeren
Copy link
Collaborator

This might be fixed with #512, released in Breathe v4.17.0. Note that you also need Sphinx 3.x for recent Breathe versions. Could someone try and post results?

@vermeeren vermeeren added bug Problem in existing code code Source code labels May 1, 2020
@Luthaf
Copy link

Luthaf commented Sep 12, 2020

I still get a similar error related to two SFINAE methods with doxygen 1.8.20, sphinx 3.2.1 and breathe 4.21.0.

The code triggering the issue is reproduced below

template <typename T>
using SupportsMemoryIO = std::is_constructible<T, std::shared_ptr<MemoryBuffer>, File::Mode, File::Compression>;

class FormatFactory final {
public:
     // [...]

    /// Register a given `Format` in the factory if it supports memory IO
    template<class Format, enable_if_t<SupportsMemoryIO<Format>::value, int> = 0>
    void add_format() {
            // [...]
    }

    /// Register a given `Format` in the factory if it does not support memory IO
    template<class Format, enable_if_t<!SupportsMemoryIO<Format>::value, int> = 0>
    void add_format() {
            // [...]
    }
    // [...]
};
.. doxygenclass:: chemfiles::FormatFactory
    :members:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Problem in existing code code Source code
Projects
None yet
Development

No branches or pull requests

4 participants