Re: gcc not compiling
From: Derek Martin (code_at_pizzashack.org)
Date: 10/31/05
- Previous message: tlc: "Re: Uncontrolled user app installs"
- In reply to: Brian D. McGrew: "RE: gcc not compiling"
- Next in thread: Derek Martin: "Re: gcc not compiling"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 31 Oct 2005 14:21:23 -0500 To: For users of Fedora Core releases <fedora-list@redhat.com>
On Mon, Oct 31, 2005 at 11:05:41AM -0800, Brian D. McGrew wrote:
> Never protoctype main as a void function or else you can't get a return
> value back to the operating system.
Sure you can:
#include <stdio.h>
void main () {
printf("\nHello World!\n");
}
$ gcc -o foo foo.c
foo.c: In function `main':
foo.c:2: warning: return type of 'main' is not `int'
$ ./foo
Hello World!
[ddm@archonis ~]
$ echo $?
14
As written, the program returns the value of the last expression
executed. In this case, printf() printed 14 characters, and the
program returns that number.
However, it should be noted that this behavior is not defined by the
standard, and can't be depended upon. But if you don't want that, no
problem:
#include <stdio.h>
void main(void)
{
Printf("\nHello World!\n");
exit(0);
}
gcc -o foo foo.c
foo.c: In function `main':
foo.c:2: warning: return type of 'main' is not `int'
[ddm@archonis ~]
$ ./foo
Hello World!
[ddm@archonis ~]
$ echo $?
0
You can return whatever value you like by calling exit().
-- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0x81CFE75D
-- fedora-list mailing list fedora-list@redhat.com To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
- application/pgp-signature attachment: stored
- Previous message: tlc: "Re: Uncontrolled user app installs"
- In reply to: Brian D. McGrew: "RE: gcc not compiling"
- Next in thread: Derek Martin: "Re: gcc not compiling"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]