572 | | For Microsoft Visual Studio, this means setting level to 4 (command line /W4), |
573 | | and disabling Microsoft language extensions |
574 | | Disable MS extensions = Yes, command line option /Za |
| 572 | For Microsoft Visual Studio, this means setting level to 4 (command line /W4),[[BR]] |
| 573 | and disabling Microsoft language extensions Disable MS extensions = Yes, command line option /Za |
| 574 | |
| 575 | (You might also consider using Microsoft /Wall if available. You may find |
| 576 | [http://www.geoffchappell.com/viewer.htm?doc=studies/msvc/cl/c1xx/warnings/index.htm&tx=2,27&ts=0,3820] |
| 577 | a helpful guide to the byzantine complexity of warnings).[[BR]] |
661 | | |
662 | | |
663 | | |
| 664 | === Specific warnings and suggested actions. === |
| 665 | |
| 666 | ''These are just few for starters and need more especially for gcc. Suggestions may be wrong! Also need reordering in a table.'' |
| 667 | |
| 668 | '''Microsoft''' |
| 669 | |
| 670 | If you chose to suppress (rather than fix by recoding), |
| 671 | localise the warnings as far as possible by using push'n'pop pragmas (see above). |
| 672 | |
| 673 | 1 C4512 assignment operator could not be generated |
| 674 | |
| 675 | Suppress using push'n'pop for the module(s) causing the warning. |
| 676 | //# pragma warning(disable: 4512) // assignment operator could not be generated |
| 677 | |
| 678 | |
| 679 | 2 C4996 'putenv': The POSIX name for this item is deprecated.[[BR]] |
| 680 | and many other messages about using secure versions. |
| 681 | |
| 682 | Unless you believe that the 'secure' versions are useful, suppress with |
| 683 | # pragma warning(disable: 4996) // '' was declared deprecated |
| 684 | |
| 685 | 3 C4127 conditional expression is constant[[BR]] |
| 686 | |
| 687 | Very common and many believe unhelpful, but a few find it informative, so do not suppress globally. |
| 688 | |
| 689 | Even while(true) can trigger this! Suppress.[[BR]] |
| 690 | |
| 691 | # pragma warning(disable: 4127) // conditional expression is constant |
| 692 | |
| 693 | 4 C4100 unreferenced formal parameter |
| 694 | |
| 695 | Either surround the parameter with C comments, for example: int */ my_variable */) |
| 696 | or just delete if the variable name is uninformative. |
| 697 | |
| 698 | 5 C4701 local variable may be used without having been initialized |
| 699 | |
| 700 | Best is to recode to avoid the message, but if you are '''very''' sure the message is misleading, suppress. |
| 701 | |
| 702 | # pragma warning(disable: 4701) // local variable may be used without having been initialized |
| 703 | |
| 704 | 6 c4511 copy constructor could not be generated |
| 705 | |
| 706 | This can almost certainly be suppressed. |
| 707 | # pragma warning(disable: 4511) // copy constructor could not be generated |
| 708 | |
| 709 | 7 C4180 qualifier applied to function type has no meaning; ignored |
| 710 | |
| 711 | This can always be suppressed - but check that you didn't mean to put the const somewhere else. |
| 712 | |
| 713 | 8 C4702 unreachable code |
| 714 | |
| 715 | Be very cautious about suppressing this, but use of macros may make this troublesome, |
| 716 | so suppress with care, and always locally. |
| 717 | |
| 718 | #pragma warning(disable: 4702) // unreachable code |
| 719 | |
| 720 | 9 C4189 local variable is initialized but not referenced |
| 721 | |
| 722 | This probably indicates a redundant variable and assignment, so probably remove it. |
| 723 | |
| 724 | If you sure it is required (or has negligible cost for some documentation benefit), suppress. |
| 725 | |
| 726 | 10 C4224 nonstandard extension used : formal parameter 'arg' was previously defined as a type. |
| 727 | |
| 728 | This will bite users who try to compile with Microsoft extensions disabled. |
| 729 | So is most undesirable, but may be a major nuisance to change the names in code. |
| 730 | However fixing is the Right Thing, but meanwhile suppressing may be helpful. |
| 731 | |
| 732 | # pragma warning(disable: 4224) // formal parameter 'arg' was previously defined as a type. |
| 733 | |
| 734 | 11 C4510 default constructor could not be generated |
| 735 | |
| 736 | Suppress. |
| 737 | |
| 738 | 12 C4800 int' : forcing value to bool 'true' or 'false' |
| 739 | |
| 740 | Suppress. |
| 741 | |
| 742 | 13 C4244 // Conversion: possible loss of data. |
| 743 | |
| 744 | Fix, for example changing type or using static_cast is best, suppress with much caution. |
| 745 | |
| 746 | # pragma warning(disable:4244) // Conversion: possible loss of data. |
| 747 | |
| 748 | 14 C4324 structure was padded due to __declspec(align()) |
| 749 | |
| 750 | Suppress |
| 751 | |
| 752 | #pragma warning(disable:4324) // structure was padded due to __declspec(align()) |
| 753 | |
| 754 | '''GCC''' |
| 755 | |
| 756 | 1 class does not have a virtual destructor |
| 757 | |
| 758 | Suppress or provide a virtual destructor. |
| 759 | |