What I'm trying to do is find all explicit casts from type double or float to any other type in some source files I have. Is there a built-in gcc way to do this? Language is C. Thanks!
This warning is enabled by -Wall or -Wextra . Warn when a #pragma directive is encountered that is not understood by GCC. If this command-line option is used, warnings are even issued for unknown pragmas in system header files. This is not the case if the warnings are only enabled by the -Wall command-line option.
-Wno-coverage-invalid-line-number can be used to disable the warning or -Wno-error=coverage-invalid-line-number can be used to disable the error. Suppress warning messages emitted by #warning directives.
You can use a #pragma warning directive to control the level of warning that's reported at compile time in specific source files. Warning pragma directives in source code are unaffected by the /w option.
The C++ compiler comes with a lot of useful warnings that warn you about potential errors and issues in your code. You always want to compile with warnings. A warning flag starts with -W and then the name of the warning, for example -Wconversion which warns about implicit conversions.
If your C code can also be compiled in C++ mode, you can use g++'s -Wold-style-cast
warning flag to trigger a warning on all such casts.
You can determine whether Clang has any warnings which will trigger for a particular coding pattern by using its -Weverything
switch (but note that this is not useful for almost any other purpose -- clang has disabled-by-default warnings which trigger on various forms of legitimate code). However, in this case, clang does not have any warnings which trigger on such casts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With