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

Template Specialization leads to Warning "duplicate registration of link name" #235

Open
Reen opened this issue Jan 17, 2023 · 0 comments
Open

Comments

@Reen
Copy link

Reen commented Jan 17, 2023

Hi,

I'm trying to use standardese with a complex C++14 codebase. One file gives the following warning:
[standardese linker] [warning] MyNamespace::Constants>::PI: duplicate registration of link name 'MyNamespace::Constants>::PI'
The respective code looks like this:

namespace MyNamespace
{
/**
 * \brief A class that holds mathematical constants.
 */
template<class T>
class Constants
{
};

/**
 * \brief A class that holds mathematical constants as float.
 */
template<>
class Constants<float>
{
public:
    static constexpr float PI = 3.14159265F;       //< Ratio of a circle's circumference to its diameter.

    //...
};

/**
 * \brief A class that holds mathematical constants as double.
 */
template<>
class Constants<double>
{
public:
    static constexpr double PI = 3.1415926535897932;       //< Ratio of a circle's circumference to its diameter.

    //...
};
}

I took some time debugging this issue. The best I came up with is that the method get_template_parameters in comment.cpp doesn't seem to handle this situation properly. For template classes it adds the template parameters within angular brackets, but for template specializations, it just appends a opening angular bracket, then replaces this with a closing angular bracket.
I'm not quite sure about the correct solution to this problem, otherwise I would have written a PR. My best guess is, that I would have to cast the entity to cppast::cpp_class_template_specialization and then add the unexposed arguments into angular brackets. But, would I need to do some further formatting on the list of unexposed arguments or could I just put them there literally?

Thanks for your help,
René

@Reen Reen changed the title Template Specialization lead to Warning "duplicate registration of link name" Template Specialization leads to Warning "duplicate registration of link name" Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant