Does anybody know if Cppcheck can detect which initialization syntax is used or not? If so, I'll be glad if you can point me to corresponding source code. My goal is to report initialization syntax of variables in the XML dump.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I want to check if a variable is initialized using uniform initalization or some other form. Currently it's not in the dump. I'm guessing Cppcheck has to deal with how variables are initialized at some point so I think it should be possible to find it out.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi.
Does anybody know if Cppcheck can detect which initialization syntax is used or not? If so, I'll be glad if you can point me to corresponding source code. My goal is to report initialization syntax of variables in the XML dump.
I am not sure what you want to report.. can you give me an example code? I have the feeling you have the information you need in the xml dump.
I want to check if a variable is initialized using uniform initalization or some other form. Currently it's not in the dump. I'm guessing Cppcheck has to deal with how variables are initialized at some point so I think it should be possible to find it out.
Example code:
you can see in the dump that
x
is initialized with{}
and thaty
is initialized with=
. Look in the<token..
.I'd suggest something like:
I thought about it but it fails in arrays. For example:
Now I can of course handle this case but in case there are some special cases that I might miss, I wanted to ask if Cppcheck does it internally.
you need to parse out the exact details.
I don't consider myself very knowledgeable so I'm trying to resort to existing solutions. Anyways I did it myself in the end. All good.
well you did it in the end so I think there are many kinds of checks you could implement.