Use cppcheck Code
(Jinqing's column)
Cppcheck is an static analysis tool for C/C ++ code.
Cppcheck homepage:
Http://cppcheck.sourceforge.net/
For instructions, see:
Http://cppcheck.sourceforge.net/manual.html
After you download and install cppcheck, you can test it as follows:
D: \ temp \ cppcheck -- enable = all -- template = vs D: \ code \ Server 2> D: \ temp \ result.txt
Open all check items and use the incorrect report format of vsto export the result to result.txt.
For ease of use in VC, create a BAT file, vscppcheck. bat
Cppcheck -- enable = all -- template = vs % 1> NUL
Because only cerr output is required, cout is output to NUL.
Then, choose vs> Tools> external tools to add:
Title: cppcheck
Command: D: \ jinq \ vscppcheck. bat
Parameter: $ (solutiondir)
Use Output Window
After setting this parameter, you only need to click the cppcheck menu to output the code check result and press <F4> to jump to the error line.
The trial results show many errors that should pass in parameters by reference but PASS Parameters by value, such:
D: \ code \ Server \ region \ logic \ roommgr. cpp (20): Performance: function parameter 'sroomname' shocould be passed by reference.