void main(int argc, char *argv[]) question

From: Carlos Sevillano (carlos_sevillano@ureach.com)
Date: Sat Sep 11 2004 - 15:52:56 EDT


Solaris 2.8
GCC 2.95.3 "SMCgcc"
jedit, ddd, gdb

In trying to compile some old test Unix C programs... I was not
able to compile the programs. After a while of tying to debug
the programs that were of format:

void main(int argc, char *argv[])
or

void
main(int argc, char *argv[])

failed to compile with errors on main:

# gcc -pg prog03.02.c -o prog032
prog03.02.c: In function `main':
prog03.02.c:15: warning: return type of `main' is not `int'

The program compiled fine by removing "void" from the function
main. Why do those old UNIX programs used void ... it must have
been valid at some point ... there are quite a lot of such
programs in Unix books ei Practical Unix programing, Rago Unix
System Programming, Oreilly Unix System Programming etc.

What was the use of "void" as originally intended (granted it
seems not work now days). Did the language evolved (I tried
-ansi on compiling trying with the same type of errors). There
is a lot of usage of void in the Unix programming literature.

My question is in a nutshell can someone explain the usage where
it is ok to use void () and where it is not keeping in mind
there a quite a lot of function prototypes that use void ei:

main(void)
void handler(int)
void main(int argc, char *argv[])

void
main(int argc, char *argv[])

There is also:

main()
int main(int argc, char *argv[]);

Carlos

________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:29:25 EDT