I am running cppcheck on a project, and when I do, I have been getting a warning stating there is an "uninitialized member variable" (with error code [uninitMemberVar]). If I go and check the variable it is yelling about, it is always a pointer, which is correctly initialized to nullptr
, albeit in the header file. I am doing all of my (pointer) initialization in the header file, rather than in the constructor.
I have found that I can suppress this warning by adding //cppcheck-suppress uninitMemberVar
comment, although it only works if I add it before the default constructor in the header file, rather than before the variable itself.
I am wondering if anyone has experienced a similar issue with cppcheck before, where you have initialized a pointer but cppcheck still throws a "uninitialized member variable warning"? I am not sure what is causing this, and I would like to find a solution that is better than adding cppcheck-suppress
comments. Thanks in advance for any help.
Aucun commentaire:
Enregistrer un commentaire