warning: cast from
`const std::_Vector_iterator<T_Test, std::allocator<T_Test> >* const' to
`std::_Vector_const_iterator<T_Test, std::allocator<T_Test> >*' discards
qualifiers from pointer target type
Why do I have this warning with vectors of struct or Class ?
I think that something is missed in your example. But I see that two members of your structure have the same name. Please show the exact example of your code that generates the warning.
I edited my first post, this is what I tested (very simple case, my code is long so I didn't posted it here) and I got this warning ...
Can you see anything ?
Vlad --> In my first post, you have what I tested and i've got the warning, the .h and .cpp
Peter87 -->Did you compile it ? Did you have the warning ? If not, do you have any Idee of where could the problem come from ? the compiler maybe ?
I don't have a compiler here at the moment so I compiled it on ideone.com without any warnings. You shouldn't get that warning from that code. Are you sure you get a warning when you compile exactly that code? Sometimes people make the mistake and think they compile a file but instead compile some other file. Make sure you compile the correct files. If you use an IDE, create a new project, add the files to the project, compile and see if that changes anything.
Yeah you are leaving out a lot of code and it is hard to diagnose, but it looks like you are doing something inside a const member function (through some chain of calls or a const object), and you are modifying what you have promised not to modify. You will have to track it down, or you can post some actual code that is relevant.
To echo what everyone else has been saying, the code you posted does not generate that warning. You need to post the code that does. You apparently are leaving out the most important code.
The warning comes from inside the standard library files so maybe the implementation is to blame? You could try upgrading to a more recent GCC version.
First of all thank you for your answers.
Secondly, I SWEAR you that I've got this warning with THIS code, I have no reason to lie or hide something..
I compiled this example to show you that it does not come from a complex code but just from that very simple example. And everytime, I use vectors, I got this warnings, whatever the code behind.
clanmjc ---> I will try to look ine the libraries to find what could be wrong
Peter ---> I would love to upgrade to the newest gcc, but I compile for QNX 6.3 and this is the best version I can have (maybe I could upgrade to 3.3.5)
Sorry for my english, and one more time I thank you for your effort !
Can you see something else or should I give up and use vectors with this warnings ?