In the short snippet of C code below:
#include <stdio.h>
int main() {
int i1, i2;
float f1, f2;
scanf("%d %d\n%f %f[^\n]%*c", &i1, &i2, &f1, &f2);
printf("%d %d\n", i1, i2);
printf("%f %f\n", f1, f2);
return 0;
}
How does one disable this cert-err34-c warning:
Clang-Tidy: '
scanf
' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol
' instead
I tried to look at this one: Concise way to disable specific warning instances in Clang
Then did something like that:
#include <stdio.h>
int main() {
int i1, i2;
float f1, f2;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "cert-err34-c"
scanf("%d %d\n%f %f[^\n]%*c", &i1, &i2, &f1, &f2);
#pragma clang diagnostic pop
printf("%d %d\n", i1, i2);
printf("%f %f\n", f1, f2);
return 0;
}
But now I'm getting:
Pragma diagnostic expected option name (e.g. "
-Wundef
")
I can't find where is the related -Wxxxx
flag, any idea?
Also already answered there: Inline way to disable clang-tidy checks