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

Compilation error on MSVC 16.4.2 #26

Closed
RT2Code opened this issue Dec 19, 2019 · 5 comments
Closed

Compilation error on MSVC 16.4.2 #26

RT2Code opened this issue Dec 19, 2019 · 5 comments

Comments

@RT2Code
Copy link

RT2Code commented Dec 19, 2019

Hello,

When trying to build a project using nano-signal-slot, I get the following error :

Error C7510 'static_pointer_cast': use of dependent template name must be prefixed with 'template'

From this line in nano_observer.hpp :
line 111: MT_Policy::static_pointer_cast<Observer>(observer)->remove(slot.delegate);

I'm using Visual studio 2019 version 16.4.2 with C++17 and conformant mode enabled.

If I try to fix this error by adding the template keyword like this :
line 111: MT_Policy::template static_pointer_cast<Observer>(observer)->remove(slot.delegate);

Then I get the following error :
Error C2243 'static_cast': conversion from 'Nano::ST_Policy::Weak_Ptr' to 'T *' exists, but is inaccessible

Which can be fixed by changing the inheritance mode of MT_Policy to public (though it's probably not the best way to fix it) :
line 13: class Observer : public MT_Policy

@NoAvailableAlias
Copy link
Owner

Thanks for reporting this issue, I'll take a look after work today. I was sure permissive- was being used already.

@RT2Code
Copy link
Author

RT2Code commented Dec 19, 2019

I just tried with permissive+, and I'm having the same error. Maybe it is related to a newer version of MSVC?

@NoAvailableAlias
Copy link
Owner

NoAvailableAlias commented Dec 19, 2019

I was previously using 16.4.0 and now with permissive- I am encountering this issue.
However, I'm not sure why it complains about accessibility with protected policy inheritance.
Public inheritance isn't desirable and defeats the encapsulation that the policy system provided.

Naturally reinterpret_cast allows even private policy inheritance and might be the solution if it can be proven safe.

Fix will be soon, the static cast must be made in Observer and not in the policy.

@RT2Code
Copy link
Author

RT2Code commented Dec 20, 2019

Awesome, thanks for the very quick fix. I just tried your library again, and the performances are top-notch, very nice work.

@NoAvailableAlias
Copy link
Owner

No problem, glad you like the library, and thanks again for reporting the issue.
I have published the 2.0.1 release.

ras0219-msft pushed a commit to microsoft/vcpkg that referenced this issue Dec 21, 2019
* [nano-signal-slot] Update to latest version

I know that official releases should be preferred, but I used the latest commit instead because it fix an issue which was causing compilations error on the latest MSVC version (NoAvailableAlias/nano-signal-slot#26).

* [nano-signal-slot] Fix wrong date format

* [nano-signal-slot] Version update

The developer of this library has just added a new release version including the MSVC compilation bug fix.
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

2 participants