Community
Participate
Working Groups
Created attachment 173980 [details] Files to reproduce the problem I have a couple of variables declared and defined like this : ----Vector.h---- class Vector { }; extern "C" const Vector ZERO; ----Vector4.h---- struct Vector4 { float x, y, z, w; }; ----constants.cpp---- #include "Vector4.h" extern "C" { Vector4 ZERO = { 0.f, 0.f, 0.f, 0.f }; }; ----testVector.cpp---- #include "Vector.h" void testFunc(Vector v) { } int main() { testFunc(ZERO); // <-- problem return 0; } A ProblemBinding is generated because it thinks ZERO is a Vector4 instead of a Vector.
Here the index behaves like a linker, it identifies the two variables with each other. In many use-cases this will be the expected behavior. I don't see how the indexer could know whether or not two global variables with the same name are supposed to be identifed or not.
(In reply to comment #1) > Here the index behaves like a linker, it identifies the two variables with each > other. In many use-cases this will be the expected behavior. I don't see how > the indexer could know whether or not two global variables with the same name > are supposed to be identified or not. Hi Markus, thanks for the reply. I am not very familiar with the parser and the indexer. I will look at the code to better discuss the "issue". If that even makes sense, maybe the candidates should be "kept" and then it would iterate through those and create a correct binding.
(In reply to comment #1) > Here the index behaves like a linker, it identifies the two variables with each > other. In many use-cases this will be the expected behavior. I don't see how > the indexer could know whether or not two global variables with the same name > are supposed to be identifed or not. If they have different types, as in this case, it should be safe to assume that they should not be identified.
(In reply to Nathan Ridge from comment #3) > (In reply to comment #1) > > Here the index behaves like a linker, it identifies the two variables with each > > other. In many use-cases this will be the expected behavior. I don't see how > > the indexer could know whether or not two global variables with the same name > > are supposed to be identifed or not. > > If they have different types, as in this case, it should be safe to assume > that they should not be identified. Actually, I think two global variables with the same name should never be identified with each other unless they have the same type AND one of them is marked 'extern'.