U
Uno
Why did the commented-out prototype for printf not work?
$ gcc -Wall -Wextra u3.c -o out
$ ./out
42
$ cat u3.c
// int printf(const char *restrict format, ...);
int printf(char *, ...);
int main (void)
{
printf("42\n");
return 0;
}
// gcc -Wall -Wextra -dD -E u3.c >text1.txt
// gcc -Wall -Wextra u3.c -o out
$
Compiler complaints before I changed the prototype to something I
understood were these:
$ gcc -Wall -Wextra u3.c -o out
u3.c:2: error: expected ‘;’, ‘,’ or ‘)’ before ‘format’
u3.c: In function ‘main’:
u3.c:7: warning: implicit declaration of function ‘printf’
u3.c:7: warning: incompatible implicit declaration of built-in function
‘printf’
$ gcc -Wall -Wextra u3.c -o out
$ ./out
42
$ cat u3.c
// int printf(const char *restrict format, ...);
int printf(char *, ...);
int main (void)
{
printf("42\n");
return 0;
}
// gcc -Wall -Wextra -dD -E u3.c >text1.txt
// gcc -Wall -Wextra u3.c -o out
$
Compiler complaints before I changed the prototype to something I
understood were these:
$ gcc -Wall -Wextra u3.c -o out
u3.c:2: error: expected ‘;’, ‘,’ or ‘)’ before ‘format’
u3.c: In function ‘main’:
u3.c:7: warning: implicit declaration of function ‘printf’
u3.c:7: warning: incompatible implicit declaration of built-in function
‘printf’