2. C standards
C89
ANSI C standard X3.159-1989
Ratified as ISO/IEC 9899:1990
(therefore also referred to as C90)
GCC flags: -ansi, -std=c89, -std=iso9899:1990
C99
Newer standard - ISO/IEC 9899:1999
GCC flags: -std=c99, -std=iso9899:1999
3. Other C standards
C94/C95
GCC flags: -std=iso9899:199409
Extensions
GCC flags:
-std=gnu89 (C89 with GNU extensions)
-std=gnu99 (C99 with GNU extensions)
4. Forms of main()
void main(void)
Supported for C89, but not C99
int main(void)
C99 standard
Explicitly tells the compiler that it accepts no
command-line arguments
int main(int argc, char* argv[])
Accepts command-line arguments
5. Other forms of main()
int main(int argc, char* argv[], char* envp[])
Extension to obtain environment variables
May not work with all compilers
6. Return value
void main()
No return value
int main()
C89 requires a return value
C99 (and C++ 98) assumes a “return 0;” if a return
isn’t executed
A special case only for main(), and doesn’t apply to
other functions
7. A final note
Use int main() instead of void main() for code
portability
Get the compiler to display all warnings
Use compiler flags to try different C standards
and extensions and observe the warning and
error messages