Note that there are some explanatory texts on larger screens.

plurals
  1. POAlternative for C++ comments to silence a warning
    primarykey
    data
    text
    <p><strong>Abstract</strong> Let's say, we use a C++ statical analysis tool (Lint) that gives warnings, we process them, and then we silence these warnings by adding comments, for example NOTREACHED (Refer to <a href="http://www.thinkage.ca/english/gcos/expl/lint/manu/manu.html" rel="nofollow">LINT Reference Manual</a> for details):</p> <pre><code>int foo (char *s) { if (NULL == s) { fatal("s is null in foo"); /*NOTREACHED*/ } } </code></pre> <p>Any ideas about better place for these comments?</p> <p><strong>Problem definition</strong> I have a home-made analysis tool which uses //MULTIBYTE comments to silence it:</p> <pre><code> // check allowed values here: m_VIDEdit.GetWindowText(str1);//MULTIBYTE: passed 10/22/2013 int size1 = str1.GetLength(); int size2 = str2.GetLength(); if( !_tcsncmp( (LPCSTR)str1, (LPCSTR)str2, min( size1, size2 ) ) ) { // allow to edit default string ; //OK } </code></pre> <p>Any ideas about better place for these comments, in order not to overweight С++ code, but still silence the tool? (The tool itself can be modified in any manner)</p> <p><strong>Possible solution</strong> My idea is to use external file with structure similar to .patch files. For example, XXXWizard/XXXWizard.comments file would contain:</p> <pre><code>Index: XXXWizard/XXXWiz_Page.cpp =================================================================== --- XXXWizard/XXXWiz_Page.cpp (revision 750) +++ XXXWizard/XXXWiz_Page.cpp (working copy) @@ -454,11 +454,11 @@ CString str2 = DEFAULT_VID_VALUE_DDR3; // check allowed values here: - m_VIDEdit.GetWindowText(str1); + m_VIDEdit.GetWindowText(str1);//MULTIBYTE: passed 10/22/2013 int size1 = str1.GetLength(); int size2 = str2.GetLength(); - if( !_tcsnccmp( (LPCSTR)str1, (LPCSTR)str2, min( size1, size2 ) ) ) { // allow to edit default string + if( !_tcsncmp( (LPCSTR)str1, (LPCSTR)str2, min( size1, size2 ) ) ) { // allow to edit default string ; //OK } else { /// if it is not default string - allow only numbers here m_Owner-&gt;CheckEditNumberEntry(&amp;m_VIDEdit, true, 5000, -10); </code></pre> <p>But maybe there are better ways?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload