C-Style casts are often considered bad code practice. The problem is that it is hard to search the source code for C-Style cast. Therefore, C-style cast detection for cppcheck (optional!) would be really helpful to enforce "better" coding conventions and prevent possible hazardous casts.
Last edit: Sven Strickroth 2019-09-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hmm.. this is a integer to pointer cast . not sure maybe we did not warn about this by intention. I guess you could use reinterpret_cast but does that offer any protection at all compared to a raw C style cast?
g++ supports the flag "old-style-cast" which can be used to issue warnings on c-style cast usage in C++ code (cf. https://stackoverflow.com/a/2593492/3906760). Other compilers, such as MSVC (cf. https://developercommunity.visualstudio.com/idea/550695/add-compile-option-to-warn-on-c-style-cast-usage.html), don't have such an option ATM.
C-Style casts are often considered bad code practice. The problem is that it is hard to search the source code for C-Style cast. Therefore, C-style cast detection for cppcheck (optional!) would be really helpful to enforce "better" coding conventions and prevent possible hazardous casts.
Last edit: Sven Strickroth 2019-09-12
See cstyleCast.
Cppcheck output:
If you see some false negatives.. can you please elaborate somewhat..
How to enable this in the GUI?
e.g. https://github.com/ProgerXP/Notepad2e/blob/c724fc0ca8c837c6f67d18425edf104620b47f61/src/Notepad2.c#L5184 and https://github.com/ProgerXP/Notepad2e/blob/c724fc0ca8c837c6f67d18425edf104620b47f61/src/Notepad2.c#L5809 are not detected by default.
Last edit: Sven Strickroth 2019-09-12
hmm.. this is a integer to pointer cast . not sure maybe we did not warn about this by intention. I guess you could use reinterpret_cast but does that offer any protection at all compared to a raw C style cast?
I am not sure what are intentions was here neither.
The warning was added because C++ casts have better protection.