(Created page with 'Code is compiled with no warnings at warning level 4. Exceptions are detailed below.
===Compiling 3rd-party Code===
Code that is compiled by us but does not belong to us doe…') |
|||
Line 1: | Line 1: | ||
− | Code is compiled with no warnings at warning level 4. |
+ | Code is compiled with no warnings at warning level 4. Exceptions are detailed below. |
===Compiling 3rd-party Code=== |
===Compiling 3rd-party Code=== |
||
− | Code that is compiled by us but does not belong to us does not have to conform to our coding standards, and thus does not need to comply with this rule. |
+ | Code that is compiled by us but does not belong to us does not have to conform to our coding standards, and thus does not need to comply with this rule. Examples of this include the Microsoft system header filers, STL, other libraries which have purchased, etc. The warnings can be turned of temporarily like so: |
<pre> |
<pre> |
||
#pragma warning( push, 1 ) |
#pragma warning( push, 1 ) |
||
Line 10: | Line 10: | ||
===Disabling Warnings=== |
===Disabling Warnings=== |
||
− | "#pragma warning" may be used to disable unavoidable warnings. |
+ | "#pragma warning" may be used to disable unavoidable warnings. Two categories of warnings that are okay to disable are informational warnings, such as the compiler indicating that a function is selected to be inlined, and warnings dealing with identification of non-standard C++ usage, which is okay because all Windows code uses “Microsoft Extensions” to C++ and is common. The table below lists warnings that are okay to disable and are commonly disabled. There may be other warnings that fit in the above specified categories that are okay to disable but are not listed here. If one is found, please notify the author for inclusion in this list. All of these warnings can be turned off by including the following header file in the projects stdafx.h file: |
− | + | [clearcase]:\BuildSupport\Wonderware\Compiles\DisableWarnings.h |
|
Warning which can be turned off: |
Warning which can be turned off: |
||
*C4001 – Nonstandard extension 'single line comment' was used |
*C4001 – Nonstandard extension 'single line comment' was used |
||
− | *C4049 – Compiler limit : terminating line number emission. |
+ | *C4049 – Compiler limit : terminating line number emission. The file contains more than 65,536 (64K) source lines |
*C4152 – Non standard extension, function/data ptr conversion in expression |
*C4152 – Non standard extension, function/data ptr conversion in expression |
||
*C4200 – Nonstandard extension used : zero-sized array in struct/union |
*C4200 – Nonstandard extension used : zero-sized array in struct/union |
||
Line 35: | Line 35: | ||
===Fixing Code to Remove Warnings=== |
===Fixing Code to Remove Warnings=== |
||
− | All warnings other than the ones listed above cannot be turned off. |
+ | All warnings other than the ones listed above cannot be turned off. The table below lists some of these warnings and how to fix the code so that the warnings don’t show up. See the comment next to each warning on suggested ways to modify code to remove the warning. |
+ | <table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 width=590 style='width:6.15in;margin-left:.45in;border-collapse:collapse;border:none; mso-border-alt:solid windowtext .5pt;mso-yfti-tbllook:480;mso-padding-alt: 0in 5.4pt 0in 5.4pt'><tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'><td width=590 colspan=2 valign=top style='width:6.15in;border:solid windowtext 1.0pt; mso-border-alt:solid windowtext .5pt;background:#D9D9D9;mso-shading:windowtext; mso-pattern:gray-15 auto;padding:0in 5.4pt 0in 5.4pt'> |
||
− | <table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 width=590 |
||
+ | <p style="text-align:center"><b style='mso-bidi-font-weight:normal'><span style='font-size:12.0pt'>Fixing Code to Remove Warnings</span></b></p> |
||
− | style='width:6.15in;margin-left:.45in;border-collapse:collapse;border:none; |
||
+ | </td></tr><tr style='mso-yfti-irow:1'><td width=210 valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; background:#D9D9D9;mso-shading:windowtext;mso-pattern:gray-15 auto; padding:0in 5.4pt 0in 5.4pt'> |
||
− | mso-border-alt:solid windowtext .5pt;mso-yfti-tbllook:480;mso-padding-alt: |
||
+ | <b style='mso-bidi-font-weight: normal'>Warning</b> |
||
− | 0in 5.4pt 0in 5.4pt'> |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;background:#D9D9D9;mso-shading:windowtext; mso-pattern:gray-15 auto;padding:0in 5.4pt 0in 5.4pt'> |
||
− | <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'> |
||
+ | <b style='mso-bidi-font-weight: normal'>How to correct code</b> |
||
− | <td width=590 colspan=2 valign=top style='width:6.15in;border:solid windowtext 1.0pt; |
||
+ | </td></tr><tr style='mso-yfti-irow:2;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | mso-border-alt:solid windowtext .5pt;background:#D9D9D9;mso-shading:windowtext; |
||
+ | <b style='mso-bidi-font-weight:normal'>C4005</b> – Macro redefinition |
||
− | mso-pattern:gray-15 auto;padding:0in 5.4pt 0in 5.4pt'> |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal align=center style='margin-top:6.0pt;text-align:center'><b |
||
+ | This is probably happening because a particular header file that defines a macro is somehow getting <span style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>#include</span>d recursively.<span style='mso-spacerun:yes'> </span>Make sure header files are guarded with <span style='font-size:8.0pt;font-family:"Lucida Console"; color:blue'>#<span class=SpellE>pragma</span> once</span> |
||
− | style='mso-bidi-font-weight:normal'><span style='font-size:12.0pt'>Fixing |
||
+ | </td></tr><tr style='mso-yfti-irow:3;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | Code to Remove Warnings</span></b></p> |
||
+ | <b style='mso-bidi-font-weight:normal'>C4018 </b>– Signed/unsigned mismatch. |
||
− | </td> |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | </tr> |
||
+ | This is probably a software bug.<span style='mso-spacerun:yes'> </span>Care is taken when signed and unsigned types are used in the same expression or comparison.<span style='mso-spacerun:yes'> </span>It’s very easy to get the wrong results on larger numbers.<span style='mso-spacerun:yes'> </span>For instance, and short integer value of -5 will change to number 65531 if implicitly converted to type of short unsigned integer |
||
− | <tr style='mso-yfti-irow:1'> |
||
− | + | </td></tr><tr style='mso-yfti-irow:4;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
|
+ | <b style='mso-bidi-font-weight:normal'>C4065</b> – Switch statement contains 'default' but no 'case' labels |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | background:#D9D9D9;mso-shading:windowtext;mso-pattern:gray-15 auto; |
||
+ | This may happen with code created by a code generation such as <span class=SpellE>yacc</span> or bison.<span style='mso-spacerun:yes'> </span>Correct the input files to avoid this warning. |
||
− | padding:0in 5.4pt 0in 5.4pt'> |
||
+ | </td></tr><tr style='mso-yfti-irow:5;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:12.0pt'><b style='mso-bidi-font-weight: |
||
+ | <b style='mso-bidi-font-weight:normal'>C4067</b> – Unexpected tokens following preprocessor directive - expected a newline |
||
− | normal'>Warning</b></p> |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | </td> |
||
+ | The main reason one would get this error is because C++ used to allow arbitrary text after a preprocessor directives, such as: |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
+ | <span style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>#<span class=SpellE>ifdef</span></span><span style='font-size:8.0pt;font-family: "Lucida Console"'> _DEBUG</span> |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
+ | <span style='font-size:8.0pt;font-family:"Lucida Console"'><b><span style='color:teal'>...</span></b></span> |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
+ | <span style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>#<span class=SpellE>endif</span></span><span style='font-size:8.0pt;font-family: "Lucida Console"'> _DEBUG</span> |
||
− | mso-border-alt:solid windowtext .5pt;background:#D9D9D9;mso-shading:windowtext; |
||
+ | The text after the <span style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>#<span class=SpellE>endif</span></span> is now illegal.<span style='mso-spacerun:yes'> </span>To fix, change code to look like this: |
||
− | mso-pattern:gray-15 auto;padding:0in 5.4pt 0in 5.4pt'> |
||
+ | <span style='font-size:8.0pt;font-family:"Lucida Console"; color:blue'>#<span class=SpellE>ifdef</span></span><span style='font-size: 8.0pt;font-family:"Lucida Console"'> _DEBUG</span> |
||
− | <p class=MsoNormal style='margin-top:12.0pt'><b style='mso-bidi-font-weight: |
||
+ | <span style='font-size:8.0pt;font-family:"Lucida Console"'><b><span style='color:teal'>...</span></b></span> |
||
− | normal'>How to correct code</b></p> |
||
+ | <span style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>#<span class=SpellE>endif</span></span><span style='font-size:8.0pt;font-family: "Lucida Console"'> <span style='color:green'>// _DEBUG</span></span> |
||
− | </td> |
||
+ | |||
− | </tr> |
||
+ | |||
− | <tr style='mso-yfti-irow:2;height:12.75pt'> |
||
− | + | </td></tr><tr style='mso-yfti-irow:6;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
|
+ | <b style='mso-bidi-font-weight:normal'>C4081 </b>– Expected 'token1'; found 'token2' |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
+ | See message |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | </td></tr><tr style='mso-yfti-irow:7;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'> |
+ | <b style='mso-bidi-font-weight:normal'>C4097</b> – Expected <span class=SpellE>pragma</span> parameter to be 'token1' or 'token2' |
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | </td> |
||
+ | See message |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | + | </td></tr><tr style='mso-yfti-irow:8'><td width=210 valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt'> |
|
+ | <b style='mso-bidi-font-weight:normal'>C4100 </b>– Unreferenced formal parameter |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
+ | |||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
+ | |||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> |
||
− | margin-left:-.9pt;margin-bottom:.0001pt'>This is probably happening because a |
||
+ | There are several ways to fix this: |
||
− | particular header file that defines a macro is somehow getting <span |
||
+ | <span style='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family: Symbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span>Comment out the name of the variable in the parameter list |
||
− | style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>#include</span>d |
||
+ | <span style='font-family:Symbol; mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span>Reference the variable by itself after the return statement: |
||
− | recursively.<span style='mso-spacerun:yes'> </span>Make sure header files are |
||
− | + | <span style='font-size:8.0pt;font-family:"Lucida Console"'>…</span> |
|
+ | <span style='font-size:8.0pt;font-family:"Lucida Console"; color:blue'>return;</span> |
||
− | color:blue'>#<span class=SpellE>pragma</span> once</span></p> |
||
+ | |||
− | </td> |
||
+ | |||
− | </tr> |
||
+ | <span style='font-size:8.0pt;font-family:"Lucida Console"'>param1;<span style='color:blue'> </span><span style='color:#00B050'>// empty reference</span></span> |
||
− | <tr style='mso-yfti-irow:3;height:12.75pt'> |
||
+ | <span style='font-size:8.0pt;font-family:"Lucida Console"'>}</span> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
+ | </td></tr><tr style='mso-yfti-irow:9'><td width=210 valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt'> |
+ | <b style='mso-bidi-font-weight:normal'>C4101 </b>– Unreferenced local variable |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
+ | |||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | |||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> |
||
− | style='mso-bidi-font-weight:normal'>C4018 </b>– Signed/unsigned mismatch.</p> |
||
+ | It’s best to just remove the variable.<span style='mso-spacerun:yes'> </span>If it’s there because it’s used by some other code that’s currently commented out, remove the variable and code that’s commented out.<span style='mso-spacerun:yes'> </span>If the variable is there to view its result in the debugger, then you can disable this particular instance of the warning by referencing the variable immediately after the declaration: |
||
− | </td> |
||
+ | <span style='font-size:8.0pt;font-family:"Lucida Console"; color:blue'>short</span><span style='font-size:8.0pt;font-family:"Lucida Console"'><span style='mso-spacerun:yes'> </span><span class=SpellE>objectId</span> <b><span style='color:teal'>=</span></b> <span style='color:red'>0</span><b><span style='color:teal'>;</span></b> <span class=SpellE>objectId</span><b><span style='color:teal'>;</span></b> <span style='color:green'>// for debugging</span></span> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | + | </td></tr><tr style='mso-yfti-irow:10;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
|
+ | <b style='mso-bidi-font-weight:normal'>C4102</b> – Unreferenced label |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
+ | Remove the label |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | </td></tr><tr style='mso-yfti-irow:11;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>This is probably |
||
+ | <b style='mso-bidi-font-weight:normal'>C4115</b> – Named type definition in parentheses |
||
− | a software bug.<span style='mso-spacerun:yes'> </span>Care is taken when |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | signed and unsigned types are used in the same expression or comparison.<span |
||
+ | This can happen if an undefined type is used in a function prototype.<span style='mso-spacerun:yes'> </span>The compiler thinks you’re defining variable inside of parenthesis and will generate this warning.<span style='mso-spacerun:yes'> </span>Check your <span style='font-size:8.0pt; font-family:"Lucida Console";color:blue'>#include</span> list. |
||
− | style='mso-spacerun:yes'> </span>It’s very easy to get the wrong results on |
||
+ | </td></tr><tr style='mso-yfti-irow:12;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | larger numbers.<span style='mso-spacerun:yes'> </span>For instance, and |
||
+ | <b style='mso-bidi-font-weight:normal'>C4127</b> – Conditional expression is constant |
||
− | short integer value of -5 will change to number 65531 if implicitly converted |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | to type of short unsigned integer</p> |
||
+ | This can happen with some 3<sup>rd</sup> party libraries, but can also happen if we use similar tricks that expand to compile time constants for conditions. |
||
− | </td> |
||
+ | </td></tr><tr style='mso-yfti-irow:13;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | </tr> |
||
+ | <b style='mso-bidi-font-weight:normal'>C4146</b> – Unary minus operator applied to unsigned type, result still unsigned |
||
− | <tr style='mso-yfti-irow:4;height:12.75pt'> |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
+ | Should never happen in our own code.<span style='mso-spacerun:yes'> </span>If it happens in 3<sup>rd</sup> party code, disable it. |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
+ | </td></tr><tr style='mso-yfti-irow:14'><td width=210 valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt'> |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
+ | <b style='mso-bidi-font-weight:normal'>C4189 </b>– Local variable is initialized by not referenced |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'> |
+ | (see comments for <b style='mso-bidi-font-weight:normal'>C4101</b>) |
+ | </td></tr><tr style='mso-yfti-irow:15;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | 'default' but no 'case' labels</p> |
||
+ | <b style='mso-bidi-font-weight:normal'>C4192</b> – Automatically excluding 'name' while importing type library 'library' |
||
− | </td> |
||
− | + | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
|
+ | Use <span class=SpellE><span style='font-size:8.0pt;font-family:"Lucida Console"; color:blue'>no_auto_exclude</span></span><span style='font-size:8.0pt; font-family:"Lucida Console";color:blue'> </span>and <span style='font-size: 8.0pt;font-family:"Lucida Console";color:blue'>include(…) #import </span>attributes to turn <span class=SpellE>of</span> automatic exclusion of duplicates and specify names explicitly |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border |
+ | </td></tr><tr style='mso-yfti-irow:16;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
+ | <b style='mso-bidi-font-weight:normal'>C4244</b> – Conversion from 'type1' to 'type2', possible loss of data |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | If the lost of data is okay, then use <span class=SpellE><span style='font-size:8.0pt; font-family:"Lucida Console";color:blue'>static_cast</span></span> to explicitly cast the data to the correct type. |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>This may happen |
||
+ | </td></tr><tr style='mso-yfti-irow:17;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | with code created by a code generation such as <span class=SpellE>yacc</span> |
||
+ | <b style='mso-bidi-font-weight:normal'>C4245</b> – Conversion from 'type1' to 'type2', signed/unsigned mismatch |
||
− | or bison.<span style='mso-spacerun:yes'> </span>Correct the input files to |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | avoid this warning.</p> |
||
+ | See <b style='mso-bidi-font-weight:normal'>C4018</b>.<span style='mso-spacerun:yes'> </span>Make sure you understand how the data is going to get converted then use <span class=SpellE><span style='font-size: 8.0pt;font-family:"Lucida Console";color:blue'>static_cast</span></span> to explicitly cast the data to match types. |
||
− | </td> |
||
+ | </td></tr><tr style='mso-yfti-irow:18;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | </tr> |
||
+ | <b style='mso-bidi-font-weight:normal'>C4273</b> – Function' : inconsistent DLL linkage |
||
− | <tr style='mso-yfti-irow:5;height:12.75pt'> |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
+ | Use consistent <span class=SpellE><span style='font-size:8.0pt;font-family:"Lucida Console"'>dllimport</span></span><span style='font-size:8.0pt;font-family:"Lucida Console"'> </span>qualifier <span style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>__<span class=SpellE>declspec</span></span>. |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
+ | </td></tr><tr style='mso-yfti-irow:19;height:25.5pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:25.5pt'> |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
+ | <b style='mso-bidi-font-weight:normal'>C4284</b> – Return type for 'identifier:<span class=GramE>:operator</span> –>' is not a UDT or reference to a UDT.<br />Will produce errors if applied using infix notation |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:25.5pt'> |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
+ | There’s probably a syntax error here.<span style='mso-spacerun:yes'> </span>Check to ensure that the <b><span style='font-size:8.0pt;font-family:"Lucida Console"; color:teal'>-></span></b> operator is being used correctly.<span style='mso-spacerun:yes'> </span>Is the identifier on the left side valid? |
||
− | style='mso-bidi-font-weight:normal'>C4067</b> – Unexpected tokens following |
||
+ | </td></tr><tr style='mso-yfti-irow:20;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | preprocessor directive - expected a newline</p> |
||
+ | <b style='mso-bidi-font-weight:normal'>C4310</b> – Cast truncates constant value |
||
− | </td> |
||
− | + | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
|
+ | <span class=GramE>Your</span> using the wrong data type with the constant value.<span style='mso-spacerun:yes'> </span>Either pick constant in range or change the data type. |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border |
+ | </td></tr><tr style='mso-yfti-irow:21;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
+ | <b style='mso-bidi-font-weight:normal'>C4506</b> – No definition for inline function 'function' |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:3.0pt; |
||
+ | See message |
||
− | margin-left:.05in;text-indent:-2.9pt'>The main reason one would get this error |
||
+ | </td></tr><tr style='mso-yfti-irow:22;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | is because C++ used to allow arbitrary text after a preprocessor directives, |
||
+ | <b style='mso-bidi-font-weight:normal'>C4510 </b>– default constructor could not be generated |
||
− | such as:</p> |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | Create an explicit default constructor |
||
− | margin-left:.3in;margin-bottom:.0001pt;mso-layout-grid-align:none;text-autospace: |
||
+ | </td></tr><tr style='mso-yfti-irow:23;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | none'><span style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>#<span |
||
+ | <b style='mso-bidi-font-weight:normal'>C4511</b> – copy constructor could not be generated |
||
− | class=SpellE>ifdef</span></span><span style='font-size:8.0pt;font-family: |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | "Lucida Console"'> _DEBUG</span></p> |
||
+ | Create an explicit copy constructor |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | </td></tr><tr style='mso-yfti-irow:24;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | margin-left:.3in;margin-bottom:.0001pt;mso-layout-grid-align:none;text-autospace: |
||
+ | <b style='mso-bidi-font-weight:normal'>C4512</b> – assignment operator could not be generated |
||
− | none'><span style='font-size:8.0pt;font-family:"Lucida Console"'><span |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | style='mso-spacerun:yes'> </span><b><span style='color:teal'>...</span></b><span |
||
+ | Create an explicit assignment operator |
||
− | style='color:teal'></span></span></p> |
||
+ | </td></tr><tr style='mso-yfti-irow:25;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | <b style='mso-bidi-font-weight:normal'>C4530 </b>– C++ exception handler used, but unwind semantics are not enabled. Specify /<span class=SpellE>Ehsc</span> |
||
− | margin-left:.3in;margin-bottom:.0001pt;mso-layout-grid-align:none;text-autospace: |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | none'><span style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>#<span |
||
+ | Enable exception handling for the project. |
||
− | class=SpellE>endif</span></span><span style='font-size:8.0pt;font-family: |
||
+ | </td></tr><tr style='mso-yfti-irow:26;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | "Lucida Console"'> _DEBUG</span></p> |
||
+ | <b style='mso-bidi-font-weight:normal'>C4610</b> – Object 'class' can never be instantiated - user-defined constructor required |
||
− | <p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom: |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | 3.0pt;margin-left:.05in;text-indent:-2.9pt'>The text after the <span |
||
+ | Create an explicit constructor |
||
− | style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>#<span |
||
+ | </td></tr><tr style='mso-yfti-irow:27;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | class=SpellE>endif</span></span> is now illegal.<span |
||
− | style='mso- |
+ | <b style='mso-bidi-font-weight:normal'>C4663</b> – To explicitly <span class=GramE>specialize</span> a template class, use the new syntax. |
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom: |
||
+ | Add <span style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>template</span><b><span style='font-size:8.0pt;font-family:"Lucida Console";color:teal'><></span></b> in front of the class declaration for an explicitly specialized class template. |
||
− | 0in;margin-left:.3in;margin-bottom:.0001pt;mso-layout-grid-align:none; |
||
+ | </td></tr><tr style='mso-yfti-irow:28'><td width=210 valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt'> |
||
− | text-autospace:none'><span style='font-size:8.0pt;font-family:"Lucida Console"; |
||
+ | <b style='mso-bidi-font-weight:normal'>C4700 </b>– Local variable used without having been initialized |
||
− | color:blue'>#<span class=SpellE>ifdef</span></span><span style='font-size: |
||
+ | |||
− | 8.0pt;font-family:"Lucida Console"'> _DEBUG</span></p> |
||
+ | |||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> |
||
− | margin-left:.3in;margin-bottom:.0001pt;mso-layout-grid-align:none;text-autospace: |
||
+ | Be careful with this warning.<span style='mso-spacerun:yes'> </span>It could actually point to a software defect.<span style='mso-spacerun:yes'> </span>The only time this is valid to have is when a variable is passed by reference to a function.<span style='mso-spacerun:yes'> </span>The compiler doesn’t know that it’s okay for the input variable to not be initialized (C++ allows this.)<span style='mso-spacerun:yes'> </span>To remove this warning, initialize the variable before using it. |
||
− | none'><span style='font-size:8.0pt;font-family:"Lucida Console"'><span |
||
+ | </td></tr><tr style='mso-yfti-irow:29;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | style='mso-spacerun:yes'> </span><b><span style='color:teal'>...</span></b><span |
||
+ | <b style='mso-bidi-font-weight:normal'>C4701</b> – Local variable 'name' may be used without having been initialized |
||
− | style='color:teal'></span></span></p> |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | See <b style='mso-bidi-font-weight:normal'>C4700</b> |
||
− | margin-left:.3in;margin-bottom:.0001pt;mso-layout-grid-align:none;text-autospace: |
||
+ | </td></tr><tr style='mso-yfti-irow:30;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | none'><span style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>#<span |
||
+ | <b style='mso-bidi-font-weight:normal'>C4702</b> – Unreachable code |
||
− | class=SpellE>endif</span></span><span style='font-size:8.0pt;font-family: |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | "Lucida Console"'> <span style='color:green'>// _DEBUG</span></span></p> |
||
+ | Remove the dead code, or if the code isn’t dead, fix the control paths. |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | </td></tr><tr style='mso-yfti-irow:31;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'></p> |
||
+ | <b style='mso-bidi-font-weight:normal'>C4706</b> – Assignment within conditional expression |
||
− | </td> |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | </tr> |
||
+ | Assignments within conditional expressions should not be made.<span style='mso-spacerun:yes'> </span>Fix the code. |
||
− | <tr style='mso-yfti-irow:6;height:12.75pt'> |
||
− | + | </td></tr><tr style='mso-yfti-irow:32;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
|
+ | <b style='mso-bidi-font-weight:normal'>C4710</b> – Function not <span class=SpellE>inlined</span> |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
+ | Remove the <span style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>inline </span>keyword. |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | </td></tr><tr style='mso-yfti-irow:33'><td width=210 valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt'> |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'> |
+ | <b style='mso-bidi-font-weight:normal'>C4715 </b>– Not all control paths return a value |
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> |
||
− | 'token2'</p> |
||
+ | If the compiler is correct, this usually indicates a software defect and the code <span class=GramE>needs</span> to be fixed.<span style='mso-spacerun:yes'> </span>The compiler is sometimes wrong.<span style='mso-spacerun:yes'> </span>For instance, it may not know that a function you are calling never returns (such as <span class=SpellE><span class=GramE>ThrowError</span></span><span class=GramE>(</span>).)<span style='mso-spacerun:yes'> </span>Simply change the code to throw anything immediately after, or simply return. |
||
− | </td> |
||
− | + | </td></tr><tr style='mso-yfti-irow:34;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
|
+ | <b style='mso-bidi-font-weight:normal'>C4800</b> – Forcing value to <span class=SpellE>bool</span> 'true' or 'false' (performance warning) |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
+ | This happens when trying to convert a BOOL (or <span class=SpellE><span style='font-size: 8.0pt;font-family:"Lucida Console";color:blue'>int</span></span>) to C++ <span class=SpellE><span style='font-size:8.0pt;font-family:"Lucida Console"; color:blue'>bool</span></span>.<span style='mso-spacerun:yes'> </span>Example: |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
+ | <span class=SpellE><span style='font-size:8.0pt; font-family:"Lucida Console";color:blue'>bool</span></span><span style='font-size:8.0pt;font-family:"Lucida Console"'> flag <b><span style='color:teal'>=</span></b> <span class=SpellE>fFlag</span><b><span style='color:teal'>;</span></b></span> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | Doing so is a performance issue so the compiler won’t let you even cast to <span class=SpellE><span style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>bool</span></span>.<span style='mso-spacerun:yes'> </span>To fix, do this: |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>See message</p> |
||
+ | <span class=SpellE><span style='font-size:8.0pt;font-family:"Lucida Console"; color:blue'>bool</span></span><span style='font-size:8.0pt;font-family:"Lucida Console"'> flag <b><span style='color:teal'>=</span></b> <span class=SpellE>fFlag</span> <b><span style='color:teal'>!= </span></b><span style='color:red'>0</span><b><span style='color:teal'>;</span></b></span> |
||
− | </td> |
||
+ | |||
− | </tr> |
||
+ | |||
− | <tr style='mso-yfti-irow:7;height:12.75pt'> |
||
− | + | </td></tr><tr style='mso-yfti-irow:35;mso-yfti-lastrow:yes;height:12.75pt'><td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
|
+ | <b style='mso-bidi-font-weight:normal'>C4996</b> – ‘function': was declared deprecated |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
+ | </td><td width=380 valign=top style='width:285.3pt;border-top:none;border-left: none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
+ | Must not use deprecated functions unless explicitly identified in the project development plan as to why. |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
+ | </td></tr></table> |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4097</b> – Expected <span class=SpellE>pragma</span> |
||
− | parameter to be 'token1' or 'token2'</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>See message</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:8'> |
||
− | <td width=210 valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt'> |
||
− | <p class=MsoNormal style='margin-top:2.0pt;margin-right:0in;margin-bottom: |
||
− | 0in;margin-left:.55in;margin-bottom:.0001pt;text-indent:-.55in'><b |
||
− | style='mso-bidi-font-weight:normal'>C4100 </b>– Unreferenced formal parameter</p> |
||
− | <p class=MsoNormal style='margin-top:12.0pt;margin-right:0in;margin-bottom: |
||
− | 2.0pt;margin-left:.25in;text-indent:-.25in'></p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:2.0pt; |
||
− | margin-left:-.9pt'>There are several ways to fix this:</p> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:2.0pt; |
||
− | margin-left:17.1pt;text-indent:-.25in;mso-list:l1 level1 lfo4;tab-stops:list 1.5in'><span |
||
− | style='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family: |
||
− | Symbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> |
||
− | </span></span></span>Comment out the name of the variable in the |
||
− | parameter list</p> |
||
− | <p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom: |
||
− | 2.0pt;margin-left:17.3pt;text-indent:-.25in;mso-list:l1 level1 lfo4; |
||
− | tab-stops:list 1.5in'><span style='font-family:Symbol; |
||
− | mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol'><span |
||
− | style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> |
||
− | </span></span></span>Reference the variable by itself after the |
||
− | return statement:</p> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:2.0pt; |
||
− | margin-left:.5in'><span style='font-size:8.0pt;font-family:"Lucida Console"'>…</span></p> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:2.0pt; |
||
− | margin-left:.5in'><span style='font-size:8.0pt;font-family:"Lucida Console"; |
||
− | color:blue'>return;</span></p> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:2.0pt; |
||
− | margin-left:.5in'><span style='font-size:8.0pt;font-family:"Lucida Console"; |
||
− | color:blue'></span></p> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:2.0pt; |
||
− | margin-left:.5in'><span style='font-size:8.0pt;font-family:"Lucida Console"'>param1;<span |
||
− | style='color:blue'> </span><span style='color:#00B050'>// empty reference</span><span |
||
− | style='color:blue'></span></span></p> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:2.0pt; |
||
− | margin-left:.5in'><span style='font-size:8.0pt;font-family:"Lucida Console"'>}</span></p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:9'> |
||
− | <td width=210 valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.55in;margin-bottom:.0001pt;text-indent:-.55in'><b |
||
− | style='mso-bidi-font-weight:normal'>C4101 </b>– Unreferenced local variable</p> |
||
− | <p class=MsoNormal style='margin-top:2.0pt;margin-right:0in;margin-bottom: |
||
− | 0in;margin-left:.25in;margin-bottom:.0001pt;text-indent:-.25in'><b |
||
− | style='mso-bidi-font-weight:normal'></b></p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:2.0pt; |
||
− | margin-left:-.9pt'>It’s best to just remove the variable.<span |
||
− | style='mso-spacerun:yes'> </span>If it’s there because it’s used by some other |
||
− | code that’s currently commented out, remove the variable and code that’s |
||
− | commented out.<span style='mso-spacerun:yes'> </span>If the variable is |
||
− | there to view its result in the debugger, then you can disable this |
||
− | particular instance of the warning by referencing the variable immediately |
||
− | after the declaration:</p> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:2.0pt; |
||
− | margin-left:12.6pt'><span style='font-size:8.0pt;font-family:"Lucida Console"; |
||
− | color:blue'>short</span><span style='font-size:8.0pt;font-family:"Lucida Console"'><span |
||
− | style='mso-spacerun:yes'> </span><span class=SpellE>objectId</span> <b><span |
||
− | style='color:teal'>=</span></b> <span style='color:red'>0</span><b><span |
||
− | style='color:teal'>;</span></b> <span class=SpellE>objectId</span><b><span |
||
− | style='color:teal'>;</span></b> <span style='color:green'>// for debugging</span></span></p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:10;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4102</b> – Unreferenced label</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Remove the label</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:11;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4115</b> – Named type definition in |
||
− | parentheses</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>This can happen |
||
− | if an undefined type is used in a function prototype.<span |
||
− | style='mso-spacerun:yes'> </span>The compiler thinks you’re defining |
||
− | variable inside of parenthesis and will generate this warning.<span |
||
− | style='mso-spacerun:yes'> </span>Check your <span style='font-size:8.0pt; |
||
− | font-family:"Lucida Console";color:blue'>#include</span> list.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:12;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4127</b> – Conditional expression is |
||
− | constant</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>This can happen |
||
− | with some 3<sup>rd</sup> party libraries, but can also happen if we use similar |
||
− | tricks that expand to compile time constants for conditions.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:13;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4146</b> – Unary minus operator applied |
||
− | to unsigned type, result still unsigned</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Should never |
||
− | happen in our own code.<span style='mso-spacerun:yes'> </span>If it happens |
||
− | in 3<sup>rd</sup> party code, disable it.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:14'> |
||
− | <td width=210 valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.55in;margin-bottom:.0001pt;text-indent:-.55in'><b |
||
− | style='mso-bidi-font-weight:normal'>C4189 </b>– Local variable is initialized |
||
− | by not referenced<b style='mso-bidi-font-weight:normal'></b></p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:2.0pt; |
||
− | margin-left:-.9pt'>(see comments for <b style='mso-bidi-font-weight:normal'>C4101</b>)</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:15;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4192</b> – Automatically excluding |
||
− | 'name' while importing type library 'library'</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Use <span |
||
− | class=SpellE><span style='font-size:8.0pt;font-family:"Lucida Console"; |
||
− | color:blue'>no_auto_exclude</span></span><span style='font-size:8.0pt; |
||
− | font-family:"Lucida Console";color:blue'> </span>and <span style='font-size: |
||
− | 8.0pt;font-family:"Lucida Console";color:blue'>include(…) #import </span>attributes |
||
− | to turn <span class=SpellE>of</span> automatic exclusion of duplicates and |
||
− | specify names explicitly</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:16;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4244</b> – Conversion from 'type1' to |
||
− | 'type2', possible loss of data</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>If the lost of |
||
− | data is okay, then use <span class=SpellE><span style='font-size:8.0pt; |
||
− | font-family:"Lucida Console";color:blue'>static_cast</span></span> to |
||
− | explicitly cast the data to the correct type.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:17;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4245</b> – Conversion from 'type1' to |
||
− | 'type2', signed/unsigned mismatch</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>See <b |
||
− | style='mso-bidi-font-weight:normal'>C4018</b>.<span |
||
− | style='mso-spacerun:yes'> </span>Make sure you understand how the data is |
||
− | going to get converted then use <span class=SpellE><span style='font-size: |
||
− | 8.0pt;font-family:"Lucida Console";color:blue'>static_cast</span></span> to |
||
− | explicitly cast the data to match types.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:18;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4273</b> – Function' : inconsistent DLL |
||
− | linkage</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Use consistent <span |
||
− | class=SpellE><span style='font-size:8.0pt;font-family:"Lucida Console"'>dllimport</span></span><span |
||
− | style='font-size:8.0pt;font-family:"Lucida Console"'> </span>qualifier <span |
||
− | style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>__<span |
||
− | class=SpellE>declspec</span></span>.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:19;height:25.5pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:25.5pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4284</b> – Return type for 'identifier:<span |
||
− | class=GramE>:operator</span> –>' is not a UDT or reference to a UDT. <br> |
||
− | Will produce errors if applied using infix notation</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:25.5pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>There’s probably |
||
− | a syntax error here.<span style='mso-spacerun:yes'> </span>Check to ensure |
||
− | that the <b><span style='font-size:8.0pt;font-family:"Lucida Console"; |
||
− | color:teal'>-></span></b> operator is being used correctly.<span |
||
− | style='mso-spacerun:yes'> </span>Is the identifier on the left side valid?</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:20;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4310</b> – Cast truncates constant value</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'><span |
||
− | class=GramE>Your</span> using the wrong data type with the constant |
||
− | value.<span style='mso-spacerun:yes'> </span>Either pick constant in range |
||
− | or change the data type.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:21;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4506</b> – No definition for inline |
||
− | function 'function'</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>See message</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:22;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4510 </b>– default constructor could not |
||
− | be generated</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Create an |
||
− | explicit default constructor</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:23;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4511</b> – copy constructor could not be |
||
− | generated</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Create an |
||
− | explicit copy constructor</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:24;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4512</b> – assignment operator could not |
||
− | be generated</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Create an |
||
− | explicit assignment operator</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:25;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4530 </b>– C++ exception handler used, |
||
− | but unwind semantics are not enabled. Specify /<span class=SpellE>Ehsc</span></p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Enable exception |
||
− | handling for the project.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:26;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4610</b> – Object 'class' can never be |
||
− | instantiated - user-defined constructor required</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Create an |
||
− | explicit constructor</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:27;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4663</b> – To explicitly <span |
||
− | class=GramE>specialize</span> a template class, use the new syntax.</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Add <span |
||
− | style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>template</span><b><span |
||
− | style='font-size:8.0pt;font-family:"Lucida Console";color:teal'><></span></b> |
||
− | in front of the class declaration for an explicitly specialized class |
||
− | template.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:28'> |
||
− | <td width=210 valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt'> |
||
− | <p class=MsoNormal style='margin-top:2.0pt;margin-right:0in;margin-bottom: |
||
− | 0in;margin-left:.55in;margin-bottom:.0001pt;text-indent:-.55in'><b |
||
− | style='mso-bidi-font-weight:normal'>C4700 </b>– Local variable used without |
||
− | having been initialized<b style='mso-bidi-font-weight:normal'></b></p> |
||
− | <p class=MsoNormal style='margin-top:2.0pt;margin-right:0in;margin-bottom: |
||
− | 0in;margin-left:.25in;margin-bottom:.0001pt;text-indent:-.25in'><b |
||
− | style='mso-bidi-font-weight:normal'></b></p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> |
||
− | <p class=MsoNormal style='margin-top:0in'>Be careful with this warning.<span |
||
− | style='mso-spacerun:yes'> </span>It could actually point to a software |
||
− | defect.<span style='mso-spacerun:yes'> </span>The only time this is valid to |
||
− | have is when a variable is passed by reference to a function.<span |
||
− | style='mso-spacerun:yes'> </span>The compiler doesn’t know that it’s okay |
||
− | for the input variable to not be initialized (C++ allows this.)<span |
||
− | style='mso-spacerun:yes'> </span>To remove this warning, initialize the |
||
− | variable before using it.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:29;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4701</b> – Local variable 'name' may be |
||
− | used without having been initialized</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>See <b |
||
− | style='mso-bidi-font-weight:normal'>C4700</b></p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:30;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4702</b> – Unreachable code</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Remove the dead |
||
− | code, or if the code isn’t dead, fix the control paths.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:31;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4706</b> – Assignment within conditional |
||
− | expression</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Assignments within |
||
− | conditional expressions should not be made.<span style='mso-spacerun:yes'> |
||
− | </span>Fix the code.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:32;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4710</b> – Function not <span |
||
− | class=SpellE>inlined</span></p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Remove the <span |
||
− | style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>inline </span>keyword.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:33'> |
||
− | <td width=210 valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt'> |
||
− | <p class=MsoNormal style='margin-top:2.0pt;margin-right:0in;margin-bottom: |
||
− | 0in;margin-left:.55in;margin-bottom:.0001pt;text-indent:-.55in'><b |
||
− | style='mso-bidi-font-weight:normal'>C4715 </b>– Not all control paths return |
||
− | a value<b style='mso-bidi-font-weight:normal'></b></p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> |
||
− | <p class=MsoNormal style='margin-top:0in'>If the compiler is correct, this usually |
||
− | indicates a software defect and the code <span class=GramE>needs</span> to be |
||
− | fixed.<span style='mso-spacerun:yes'> </span>The compiler is sometimes |
||
− | wrong.<span style='mso-spacerun:yes'> </span>For instance, it may not know |
||
− | that a function you are calling never returns (such as <span class=SpellE><span |
||
− | class=GramE>ThrowError</span></span><span class=GramE>(</span>).)<span |
||
− | style='mso-spacerun:yes'> </span>Simply change the code to throw anything |
||
− | immediately after, or simply return.</p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:34;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4800</b> – Forcing value to <span |
||
− | class=SpellE>bool</span> 'true' or 'false' (performance warning)</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>This happens |
||
− | when trying to convert a BOOL (or <span class=SpellE><span style='font-size: |
||
− | 8.0pt;font-family:"Lucida Console";color:blue'>int</span></span>) to C++ <span |
||
− | class=SpellE><span style='font-size:8.0pt;font-family:"Lucida Console"; |
||
− | color:blue'>bool</span></span>.<span style='mso-spacerun:yes'> |
||
− | </span>Example:</p> |
||
− | <p class=MsoNormal style='margin-left:.5in;mso-layout-grid-align:none; |
||
− | text-autospace:none'><span class=SpellE><span style='font-size:8.0pt; |
||
− | font-family:"Lucida Console";color:blue'>bool</span></span><span |
||
− | style='font-size:8.0pt;font-family:"Lucida Console"'> flag <b><span |
||
− | style='color:teal'>=</span></b> <span class=SpellE>fFlag</span><b><span |
||
− | style='color:teal'>;</span></b><span style='color:teal'></span></span></p> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Doing so is a performance |
||
− | issue so the compiler won’t let you even cast to <span class=SpellE><span |
||
− | style='font-size:8.0pt;font-family:"Lucida Console";color:blue'>bool</span></span>.<span |
||
− | style='mso-spacerun:yes'> </span>To fix, do this:</p> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.5in;margin-bottom:.0001pt;mso-layout-grid-align:none;text-autospace: |
||
− | none'><span class=SpellE><span style='font-size:8.0pt;font-family:"Lucida Console"; |
||
− | color:blue'>bool</span></span><span style='font-size:8.0pt;font-family:"Lucida Console"'> |
||
− | flag <b><span style='color:teal'>=</span></b> <span class=SpellE>fFlag</span> |
||
− | <b><span style='color:teal'>!= </span></b><span style='color:red'>0</span><b><span |
||
− | style='color:teal'>;</span></b><span style='color:teal'></span></span></p> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'></p> |
||
− | </td> |
||
− | </tr> |
||
− | <tr style='mso-yfti-irow:35;mso-yfti-lastrow:yes;height:12.75pt'> |
||
− | <td width=210 nowrap valign=top style='width:157.5pt;border:solid windowtext 1.0pt; |
||
− | border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; |
||
− | padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:40.95pt;margin-bottom:.0001pt;text-indent:-40.5pt'><b |
||
− | style='mso-bidi-font-weight:normal'>C4996</b> – ‘function': was declared |
||
− | deprecated</p> |
||
− | </td> |
||
− | <td width=380 valign=top style='width:285.3pt;border-top:none;border-left: |
||
− | none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; |
||
− | mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; |
||
− | mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> |
||
− | <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; |
||
− | margin-left:.05in;margin-bottom:.0001pt;text-indent:-3.15pt'>Must not use |
||
− | deprecated functions unless explicitly identified in the project development plan |
||
− | as to why.</p> |
||
− | </td> |
||
− | </tr> |
||
− | </table> |
||
===Warning of Unfinished Code=== |
===Warning of Unfinished Code=== |
||
− | Do not use compiler warnings as a way to indicate and track code that needs to be finished. |
+ | Do not use compiler warnings as a way to indicate and track code that needs to be finished. Builds cannot have Warnings in them. Instead, to remind yourself of unfinished code, use #pragma message. |
+ | [[Category:Cheat]] |
Latest revision as of 00:17, 11 April 2010
Code is compiled with no warnings at warning level 4. Exceptions are detailed below.
Compiling 3rd-party Code[]
Code that is compiled by us but does not belong to us does not have to conform to our coding standards, and thus does not need to comply with this rule. Examples of this include the Microsoft system header filers, STL, other libraries which have purchased, etc. The warnings can be turned of temporarily like so:
#pragma warning( push, 1 ) #include <path to library> #pragma warning( pop )
Disabling Warnings[]
"#pragma warning" may be used to disable unavoidable warnings. Two categories of warnings that are okay to disable are informational warnings, such as the compiler indicating that a function is selected to be inlined, and warnings dealing with identification of non-standard C++ usage, which is okay because all Windows code uses “Microsoft Extensions” to C++ and is common. The table below lists warnings that are okay to disable and are commonly disabled. There may be other warnings that fit in the above specified categories that are okay to disable but are not listed here. If one is found, please notify the author for inclusion in this list. All of these warnings can be turned off by including the following header file in the projects stdafx.h file:
[clearcase]:\BuildSupport\Wonderware\Compiles\DisableWarnings.h
Warning which can be turned off:
- C4001 – Nonstandard extension 'single line comment' was used
- C4049 – Compiler limit : terminating line number emission. The file contains more than 65,536 (64K) source lines
- C4152 – Non standard extension, function/data ptr conversion in expression
- C4200 – Nonstandard extension used : zero-sized array in struct/union
- C4201 – Nonstandard extension used : nameless struct/union
- C4204 – Nonstandard extension used : non-constant aggregate initializer
- C4211 – Nonstandard extension used : redefined extern to static
- C4213 – Nonstandard extension used : cast on l-value
- C4214 – Nonstandard extension used : bit field types other than int
- C4238 – Nonstandard extension used : bit field types other than int
- C4239 – Nonstandard extension used : 'token' : conversion from 'type' to 'type'
- C4290 – C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
- C4503 – Decorated name length exceeded, name was truncated
- C4505 – Unreferenced local function has been removed
- C4514 – Unreferenced inline function has been removed
- C4699 – This warning provides informational messages about the status of precompiled headers
- C4711 – Function selected for inline expansion
- C4786 – Identifier was truncated to 'number' characters in the debug information
Fixing Code to Remove Warnings[]
All warnings other than the ones listed above cannot be turned off. The table below lists some of these warnings and how to fix the code so that the warnings don’t show up. See the comment next to each warning on suggested ways to modify code to remove the warning.
Fixing Code to Remove Warnings | |
Warning |
How to correct code |
C4005 – Macro redefinition |
This is probably happening because a particular header file that defines a macro is somehow getting #included recursively. Make sure header files are guarded with #pragma once |
C4018 – Signed/unsigned mismatch. |
This is probably a software bug. Care is taken when signed and unsigned types are used in the same expression or comparison. It’s very easy to get the wrong results on larger numbers. For instance, and short integer value of -5 will change to number 65531 if implicitly converted to type of short unsigned integer |
C4065 – Switch statement contains 'default' but no 'case' labels |
This may happen with code created by a code generation such as yacc or bison. Correct the input files to avoid this warning. |
C4067 – Unexpected tokens following preprocessor directive - expected a newline |
The main reason one would get this error is because C++ used to allow arbitrary text after a preprocessor directives, such as: #ifdef _DEBUG ... #endif _DEBUG The text after the #endif is now illegal. To fix, change code to look like this: #ifdef _DEBUG ... #endif // _DEBUG
|
C4081 – Expected 'token1'; found 'token2' |
See message |
C4097 – Expected pragma parameter to be 'token1' or 'token2' |
See message |
C4100 – Unreferenced formal parameter
|
There are several ways to fix this: · Comment out the name of the variable in the parameter list · Reference the variable by itself after the return statement: … return;
|
C4101 – Unreferenced local variable
|
It’s best to just remove the variable. If it’s there because it’s used by some other code that’s currently commented out, remove the variable and code that’s commented out. If the variable is there to view its result in the debugger, then you can disable this particular instance of the warning by referencing the variable immediately after the declaration: short objectId = 0; objectId; // for debugging |
C4102 – Unreferenced label |
Remove the label |
C4115 – Named type definition in parentheses |
This can happen if an undefined type is used in a function prototype. The compiler thinks you’re defining variable inside of parenthesis and will generate this warning. Check your #include list. |
C4127 – Conditional expression is constant |
This can happen with some 3rd party libraries, but can also happen if we use similar tricks that expand to compile time constants for conditions. |
C4146 – Unary minus operator applied to unsigned type, result still unsigned |
Should never happen in our own code. If it happens in 3rd party code, disable it. |
C4189 – Local variable is initialized by not referenced |
(see comments for C4101) |
C4192 – Automatically excluding 'name' while importing type library 'library' |
Use no_auto_exclude and include(…) #import attributes to turn of automatic exclusion of duplicates and specify names explicitly |
C4244 – Conversion from 'type1' to 'type2', possible loss of data |
If the lost of data is okay, then use static_cast to explicitly cast the data to the correct type. |
C4245 – Conversion from 'type1' to 'type2', signed/unsigned mismatch |
See C4018. Make sure you understand how the data is going to get converted then use static_cast to explicitly cast the data to match types. |
C4273 – Function' : inconsistent DLL linkage |
Use consistent dllimport qualifier __declspec. |
C4284 – Return type for 'identifier::operator –>' is not a UDT or reference to a UDT. |
There’s probably a syntax error here. Check to ensure that the -> operator is being used correctly. Is the identifier on the left side valid? |
C4310 – Cast truncates constant value |
Your using the wrong data type with the constant value. Either pick constant in range or change the data type. |
C4506 – No definition for inline function 'function' |
See message |
C4510 – default constructor could not be generated |
Create an explicit default constructor |
C4511 – copy constructor could not be generated |
Create an explicit copy constructor |
C4512 – assignment operator could not be generated |
Create an explicit assignment operator |
C4530 – C++ exception handler used, but unwind semantics are not enabled. Specify /Ehsc |
Enable exception handling for the project. |
C4610 – Object 'class' can never be instantiated - user-defined constructor required |
Create an explicit constructor |
C4663 – To explicitly specialize a template class, use the new syntax. |
Add template<> in front of the class declaration for an explicitly specialized class template. |
C4700 – Local variable used without having been initialized
|
Be careful with this warning. It could actually point to a software defect. The only time this is valid to have is when a variable is passed by reference to a function. The compiler doesn’t know that it’s okay for the input variable to not be initialized (C++ allows this.) To remove this warning, initialize the variable before using it. |
C4701 – Local variable 'name' may be used without having been initialized |
See C4700 |
C4702 – Unreachable code |
Remove the dead code, or if the code isn’t dead, fix the control paths. |
C4706 – Assignment within conditional expression |
Assignments within conditional expressions should not be made. Fix the code. |
C4710 – Function not inlined |
Remove the inline keyword. |
C4715 – Not all control paths return a value |
If the compiler is correct, this usually indicates a software defect and the code needs to be fixed. The compiler is sometimes wrong. For instance, it may not know that a function you are calling never returns (such as ThrowError().) Simply change the code to throw anything immediately after, or simply return. |
C4800 – Forcing value to bool 'true' or 'false' (performance warning) |
This happens when trying to convert a BOOL (or int) to C++ bool. Example: bool flag = fFlag; Doing so is a performance issue so the compiler won’t let you even cast to bool. To fix, do this: bool flag = fFlag != 0;
|
C4996 – ‘function': was declared deprecated |
Must not use deprecated functions unless explicitly identified in the project development plan as to why. |
Warning of Unfinished Code[]
Do not use compiler warnings as a way to indicate and track code that needs to be finished. Builds cannot have Warnings in them. Instead, to remind yourself of unfinished code, use #pragma message.