I have a weird problem in C. I have a structure and I pointed sample to that structure :
test sample;
now in the code, I call that structure through a function :
function is called something, so something(&sample) is used to point the structure in the function.
Now I need to copy values of sample to sample2 .. So I want sample2 to point to the same structure as well. So I also declared test sample2 before main, and used it as a global variable. Now when its used to point to contents in the structure in the function, sample must be called without a (*sample2).content or sample2->content. I only need to write sample2.content. I understand that this happens because sample2 declared globally… But I also get this when compiling :
comment 528 - Argument 'sample2' conceals a global declaration of the same symbol
The program runs fine, but I want to get rid of this compiler message… Why does it say that ? what does it mean ?
The issue is that inside the function if you refer to the symbol
samplethe compiler has two things to choose from. The first is the global variable and the second is the argument you provided to the function. What the compiler is doing is alerting you to the fact that it assumes you mean the local variable and not the global one.In general this is a recipe for grief and bugs, and you say that your code runs as intended. I cannot say how or why without looking at it in detail. The simplest answer is to just change the name of the argument to your function to something different or the global variable to something different.