-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Compiling failed with mscv 19.34 #52
Comments
I tried to reproduce it, but I could not able. Can you share a minimal example that caused this issue? |
#include "https://raw.githubusercontent.com/Neargye/nameof/master/include/nameof.hpp"
#include <string>
#include <iostream>
using namespace std;
struct X {
X(string aThing) noexcept : aThing(move(aThing)) {
}
string aThing;
// static constexpr auto what = NAMEOF(&X::aThing); ----> Works as expected
static constexpr auto what2 = NAMEOF_MEMBER(&X::aThing);
};
int main() {
auto xObj = X("test");
// cout << xObj.what << endl; ----> Works as expected
cout << xObj.what2 << endl;
return 0;
} |
Its working cool with gcc as we can see: With msvc: |
Thanks, @illegal-instruction-co So the main problem here is that the code tries to reach the class definition while initializing the constexpr static variable with the member's name. Note for the developers:
Note for the lib: |
Will add this to doc |
constexpr already put forward inline declaration, and why should i descript X::name out of struct ? I guess using NAMEOF macro is better approach |
I agree the Just a side note for this issue: The main difference between
The |
Stack:
C:\Users\PC\vcpkg\installed\x64-windows\include\nameof.hpp(956.19): message : see reference to variable template 'const auto static_v<nameof::detail::union_type >' compiled
1>C:\Users\PC\vcpkg\installed\x64-windows\include\nameof.hpp(961,1): message : compiled template function 'auto nameof::detail::get_member_name<pointer-to-member(0x10) See reference for creating )>(void) noexcept' instance
1>C:\Users\PC\vcpkg\installed\x64-windows\include\nameof.hpp(1098,40): message : see reference to compiled variable template 'const auto member_name_v<16>'
1>C:\Users\PC\Desktop\cartelsol\moscam-be\Entity\include\Entity/Spouse.h(28,41): message : compiled template function 'std::basic_string_view<char,std::char_traits< See reference to create char>> nameof::nameof_member<pointer-to-member(0x10)>(void) noexcept' instance
1>C:\Users\PC\vcpkg\installed\x64-windows\include\nameof.hpp(956.69): error C2296: '.*': not valid because left operand has type 'const int'
1>C:\Users\PC\vcpkg\installed\x64-windows\include\nameof.hpp(1099.29): error C2338: static_assert failed: 'Member does not have a name.'
The text was updated successfully, but these errors were encountered: