-
Extraits de http://www.slideshare.net/olvemaudal/deep-c
- Type de la fonction principale :
#include <stdlib.h>
main(void){ exit(0); }
$ gcc main.c -o main
$ gcc -std=c99 main.c -o main
/tmp/main.c:2:1: warning: return type defaults to ‘int’
main(void){ exit(0); }
- Valeur par défaut des fonctions :
int main(void){ }
$ gcc -Wall -ansi retour.c -o retour_ansi
retour.c: In function ‘main’:
retour.c:1:1: warning: control reaches end of non-void function [-Wreturn-type]
$ gcc -Wall -std=c99 retour.c -o retour_c99
$ gcc -Wall retour.c -o retour
retour.c: In function ‘main’:
retour.c:1:1: warning: control reaches end of non-void function [-Wreturn-type]
$ ./retour_ansi ; echo $?
212
$ ./retour_c99 ; echo $?
0
- Déclaration implicite :
int main(void){
printf("Bonjour !\n");
return 0;
}
$ clang -Wall implicite.c -o implicite
implicite.c:2:1: warning: implicitly declaring C library function 'printf' with type 'int (const char *, ...)'
implicite.c:2:1: note: please include the header <stdio.h> or explicitly provide a declaration for 'printf'
$ g++ -Wall implicite.c -o implicite
implicite.c: In function ‘int main()’:
implicite.c:2:35: error: ‘printf’ was not declared in this scope