#include
int main() {
int i;
scanf("%f", &i);
printf("%d", i, i ,2);
return 0;
}
clang -Wall .\warn.c
.\warn.c:5:5: warning: 'scanf' is deprecated: This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
scanf("%f", &i);
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\stdio.h:1275:20: note: 'scanf' has been explicitly marked deprecated here
_Check_return_ _CRT_INSECURE_DEPRECATE(scanf_s)
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\vcruntime.h:355:55: note: expanded from macro
'_CRT_INSECURE_DEPRECATE'
#define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT( \
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\vcruntime.h:345:47: note: expanded from macro
'_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
clang -Wall --target=x86_64-w64-mingw32 .\warn.c
gcc 使用相同头文件会显示警告
gcc -Wall .\warn.c
.\warn.c: In function 'main':
.\warn.c:5:13: warning: format '%f' expects argument of type 'float *', but argument 2 has type 'int *' [-Wformat=]
5 | scanf("%f", &i);
| ~^ ~~
| | |
| | int *
| float *
| %d
.\warn.c:6:12: warning: too many arguments for format [-Wformat-extra-args]
6 | printf("%d", i, i ,2);
|