I have one issue with Cppcheck during enable it in Vim, for normal code it works fine but normally I have typedef
and some functions which may not known by Cppcheck. For individual check, I have no problem because I can write library and rules for Cppcheck, for example mycppcheck.cfg
file:
<?xml version="1.0"?>
<def>
<!-- 2015-Oct-23 requested by Chen How -->
<function name="Printf"><noreturn>false</noreturn></function>
</def>
<def>
<podtype name="Int8" sign="s" size="1"/>
<podtype name="UInt8" sign="u" size="1"/>
<podtype name="Int16" sign="s" size="2"/>
<podtype name="UInt16" sign="u" size="2"/>
<podtype name="Int32" sign="s" size="4"/>
<podtype name="UInt32" sign="u" size="4"/>
</def>
<def>
<memory>
<alloc>my_malloc</alloc>
<dealloc>my_free</dealloc>
</memory>
</def>
When I use Cppcheck, I do the following command:
$ cppcheck --library=mycppcheck.cfg
When I use Cppcheck in Vim, how can I tell Cppcheck, for the current file, which library it should use? Without a library, Cppcheck can't identify the correct risk.
I use syntastic
as the plug-in for Vim. Is there another way to enable the Cppcheck facility without this plug-in?
I also checked the topic Which error format should be used for Vim and Cppcheck?. I think it can work for me, but I did not find the library define in this. Regarding the above topic, my first guess is changing:
set makeprg=cppcheck\ --enable=all\ %
to
set makeprg=cppcheck\ --library=mycppcheck.cfg --enable=all\ %
More findings @ syntastic
4.8. How can I pass additional arguments to a checker?
A. Almost all syntax checkers use the makeprgBuild() function. Those checkers that do can be configured using global variables. The general form of the global arguments variables is syntastic___args.
So, if you wanted to pass --my --args --here
to the Ruby mri checker, you would add this line to your vimrc file:
let g:syntastic_ruby_mri_args = "--my --args --here"
See :help syntastic-checker-options
for more information.