Ambiguous symbol
Project compiles and runs without any issues, but ReSharper reports ambiguous symbol. I'm using Visual Studio 2022 and ReSharper 2023.3, build 233.0.20231203.134406.
The code doesn't make sense, but it's a minimal repro. Just paste it into a new C++ console project.#define CAST_() cast_
#define CAST_TYPE(type) CAST_()type
#define TEST( type ) \
class type; \
inline type* CAST_TYPE(type) (int*) { return nullptr; } \
inline const type* CAST_TYPE(type) (const int*) { return nullptr; }
TEST( Bar )
class Bar {};
int main()
{
Bar bar;
}
Please sign in to leave a comment.
Hello,
This code uses the non-standard behavior of the MSVC preprocessor wrt token concatenation, see https://gcc.godbolt.org/z/58Khqhzcv
You probably want to use something like this instead:
#define CAST_ cast_
#define CAST_TYPE(type) CAST_##type
The relevant issue is https://youtrack.jetbrains.com/issue/RSCPP-31620
Hi Igor,
In my case such macros are included from a third party library and I'm not allowed to modify it.
Anyway, thank you for the explanation.
If you really need to, you can use the
__JETBRAINS_IDE__
macro to redefine some macros just for the IDE like this:#ifdef __JETBRAINS_IDE__
#define XXX
#endif