777 | 777 | |
778 | 778 | to turn off warnings from that point forward in the file of the use of deprecated declarations. Problematically, you have no way of knowing what the user had this option set to. They might have already had the warnings turned on, they might have had them set to ignore, or they might have had them set to cause an error. At the end of the file, if you do nothing else, the diagnostic for deprecated declarations stays ignored for anything that includes your file. You can set them to ignored, error, or warning at the end of the file before exiting, but you don't know which to use. This is sure to cause angst. |
779 | 779 | ====== version 4.6 Now you can restore the user's flags |
780 | 780 | For version 4.6 or later, you can save the state of the user's diagnostic flags. You can insert this around the line that causes the spurious warning: |
| 865 | The options -Wpedantic -Wall and -Wextra will enable nearly all warnings, a good start and a guide to eliminate warnings by recoding as far as possible. |
| 866 | |
| 867 | -Wall turns on the following warning flags: |
| 868 | |
| 869 | -Waddress |
| 870 | -Warray-bounds (only with -O2) |
| 871 | -Wc++11-compat |
| 872 | -Wchar-subscripts |
| 873 | -Wenum-compare (in C/ObjC; this is on by default in C++) |
| 874 | -Wimplicit-int (C and Objective-C only) |
| 875 | -Wimplicit-function-declaration (C and Objective-C only) |
| 876 | -Wcomment |
| 877 | -Wformat |
| 878 | -Wmain (only for C/ObjC and unless -ffreestanding) |
| 879 | -Wmaybe-uninitialized |
| 880 | -Wmissing-braces (only for C/ObjC) |
| 881 | -Wnonnull |
| 882 | -Wparentheses |
| 883 | -Wpointer-sign |
| 884 | -Wreorder |
| 885 | -Wreturn-type |
| 886 | -Wsequence-point |
| 887 | -Wsign-compare (only in C++) |
| 888 | -Wstrict-aliasing |
| 889 | -Wstrict-overflow=1 |
| 890 | -Wswitch |
| 891 | -Wtrigraphs |
| 892 | -Wuninitialized |
| 893 | -Wunknown-pragmas |
| 894 | -Wunused-function |
| 895 | -Wunused-label |
| 896 | -Wunused-value |
| 897 | -Wunused-variable |
| 898 | -Wvolatile-register-var |
| 899 | |
| 900 | -Wextra |
| 901 | This enables some extra warning flags that are not enabled by -Wall. (This option used to be called -W. The older name is still supported, but the newer name is more descriptive.) |
| 902 | |
| 903 | -Wclobbered |
| 904 | -Wempty-body |
| 905 | -Wignored-qualifiers |
| 906 | -Wmissing-field-initializers |
| 907 | -Wmissing-parameter-type (C only) |
| 908 | -Wold-style-declaration (C only) |
| 909 | -Woverride-init |
| 910 | -Wsign-compare |
| 911 | -Wtype-limits |
| 912 | -Wuninitialized |
| 913 | -Wunused-parameter (only with -Wunused or -Wall) |
| 914 | -Wunused-but-set-parameter (only with -Wunused or -Wall) |
| 915 | |
| 916 | The option -Wextra also prints warning messages for the following cases: |
| 917 | |
| 918 | A pointer is compared against integer zero with `<', `<=', `>', or `>='. |
| 919 | (C++ only) An enumerator and a non-enumerator both appear in a conditional expression. |
| 920 | (C++ only) Ambiguous virtual bases. |
| 921 | (C++ only) Subscripting an array that has been declared `register'. |
| 922 | (C++ only) Taking the address of a variable that has been declared `register'. |
| 923 | (C++ only) A base class is not initialized in a derived class's copy constructor. |
| 924 | |
| 925 | However, it may still be necessary to suppress those that are not providing any useful guidance and cannot be reasonably eliminated. |
| 926 | |
| 927 | Many of the method discussed above for GCC should be useful. |
| 928 | |
| 929 | (Clang is more recent and so probably uses GCC >= 4.6, so the complexity of early GCC versions is absent). |
| 930 | |
| 931 | To ignore via a command line, to an option like "-Wunused-variable" add a preceeding "no-" thus: "-Wno-unused-variable". |
| 932 | |
| 933 | In a jamfile, add |
| 934 | {{{ |
| 935 | <cxxflags>-Wno-unused-variable |
| 936 | <cxxflags>-Wno-maybe-uninitialized |
| 937 | ... |
| 938 | }}} |