cppcheck --version
Cppcheck 1.40
cppcheck --verbose --all --style --xml "main.cpp"
Checking main.cpp...
<?xml version="1.0"?>
<results>
</results>
CppCheck.h|31|memleak : possible error : Memory leak: CppCheck::m_CppCheckLog|
CppCheck.h|32|memleak : possible error : Memory leak: CppCheck::m_ListLog|
CppCheck::CppCheck()
{
if (!Manager::LoadResource(_T("CppCheck.zip")))
{
NotifyMissingFile(_T("CppCheck.zip"));
}
m_LogPageIndex = 0; // good init value ???
m_CppCheckLog = 0;
m_ListLog = 0;
m_ListLogPageIndex = 0;
m_CppCheckApp = _T("cppcheck");
} // end of constructor
cppcheck --version
Cppcheck 1.40
cppcheck --verbose --all --style --xml "base\tinyxml\tinystr.cpp" "base\tinyxml\tinywxuni.cpp" "base\tinyxml\tinyxml.cpp" "base\tinyxml\tinyxmlerror.cpp" "base\tinyxml\tinyxmlparser.cpp" "build_tools\autorevision\autorevision.cpp" "include\annoyingdialog.h" "include\autodetectcompilers.h" "include\backgroundthread.h" "include\base64.h" "include\blockallocated.h" "include\cbauibook.h" "include\cbeditor.h" "include\cbeditorprintout.h" "include\cbexception.h" "include\cbfunctor.h" "include\cbplugin.h" "include\cbproject.h" "include\cbstyledtextctrl.h" "include\cbthreadedtask.h" "include\cbthreadpool.h" "include\cbthreadpool_extras.h" "include\cbtool.h" "include\cbworkspace.h" "include\compileoptionsbase.h" "include\compiler.h" "include\compilercommandgenerator.h"
[......]
and when I use it to check c::b.
it get such result.what is the problem???Quotecppcheck --version
Cppcheck 1.40
cppcheck --verbose --all --style --xml "base\tinyxml\tinystr.cpp" "base\tinyxml\tinywxuni.cpp" "base\tinyxml\tinyxml.cpp" "base\tinyxml\tinyxmlerror.cpp" "base\tinyxml\tinyxmlparser.cpp" "build_tools\autorevision\autorevision.cpp" "include\annoyingdialog.h" "include\autodetectcompilers.h" "include\backgroundthread.h" "include\base64.h" "include\blockallocated.h" "include\cbauibook.h" "include\cbeditor.h" "include\cbeditorprintout.h" "include\cbexception.h" "include\cbfunctor.h" "include\cbplugin.h" "include\cbproject.h" "include\cbstyledtextctrl.h" "include\cbthreadedtask.h" "include\cbthreadpool.h" "include\cbthreadpool_extras.h" "include\cbtool.h" "include\cbworkspace.h" "include\compileoptionsbase.h" "include\compiler.h" "include\compilercommandgenerator.h"
[......]
The actual version of cppcheck can not handle it.
With respect to the X =NULL; ; my very strong personal feeling is not to use NULL, but use 0.
And in the future we will have a special null_ptr keyword (C++Ox) and then all discussions are over ;-)
With respect to the X =NULL; ; my very strong personal feeling is not to use NULL, but use 0.
And in the future we will have a special null_ptr keyword (C++Ox) and then all discussions are over ;-)
BTW, NULL is #define NULL 0L most of the time (not 100% sure)
/* Define NULL pointer value */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
#if defined (_STDDEF_H) || defined (__need_NULL)
#undef NULL /* in case <stdio.h> has defined it. */
#ifdef __GNUG__
#define NULL __null
#else /* G++ */
#ifndef __cplusplus
#define NULL ((void *)0)
#else /* C++ */
#define NULL 0
#endif /* C++ */
#endif /* G++ */
#endif /* NULL not defined and <stddef.h> or need NULL. */
#undef __need_NULL
Extract from some of the headers in:
VC2005:Code/* Define NULL pointer value */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
GCC 4.4.3Code#if defined (_STDDEF_H) || defined (__need_NULL)
#undef NULL /* in case <stdio.h> has defined it. */
#ifdef __GNUG__
#define NULL __null
#else /* G++ */
#ifndef __cplusplus
#define NULL ((void *)0)
#else /* C++ */
#define NULL 0
#endif /* C++ */
#endif /* G++ */
#endif /* NULL not defined and <stddef.h> or need NULL. */
#undef __need_NULL
BTW: for everyone interested in nullptr -> http://blogs.msdn.com/vcblog/archive/2009/10/27/channel-9-video-stephan-t-lavavej-everything-you-ever-wanted-to-know-about-nullptr.aspx
CppCheck.h|31|memleak : possible error : Memory leak: CppCheck::m_CppCheckLog|
CppCheck.h|32|memleak : possible error : Memory leak: CppCheck::m_ListLog|
QuoteCppCheck.h|31|memleak : possible error : Memory leak: CppCheck::m_CppCheckLog|
CppCheck.h|32|memleak : possible error : Memory leak: CppCheck::m_ListLog|
Did we miss the important thing??It seems some memory leak here. :D
Initialization lists. In fact, constructors should initialize as a rule all member objects in the initialization list. One exception is discussed further down.