I tried the below c program & I expected to get compile time error, but why compiler isn\'t giving any error?
#include
int main(void)
{
Using g++ with commandline parameter -Wall produces the following diagnostics:
g++ -Wall -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.cpp
main.cpp: In function 'int main(void)':
main.cpp:17:16: warning: format '%d' expects a matching 'int' argument [-Wformat=]
printf("%d");
^
That's pretty useful, isn't it?
gcc/g++ also check if the format specifiers actually match the parameter types. This is really cool for debugging.