GCC: Compilation using C/C++

Fabian Cenedese Cenedese@indel.ch
Mon Feb 18 07:39:00 GMT 2008


At 02:07 18.02.2008 -0300, Ricardo Sardano Guanciale wrote:
>My name is Ricardo, please can you help me?
>
>How can I compile the following ANSI C code without warnings:
>
>#include <stdio.h>
>
>void main(void)
>{
>    printf("Hello world!\n");
>}
>
>I tryed:
>
>gcc helloworld.c -o helloworld
>
>The compiler answered:
>
>helloworld.c: In function `main':
>helloworld.c:4: warning: return type of 'main' is not `int'

You need to declare it:

int main(void)
{
        return 0;
}

This return value is used for the exit code of the program.

bye  Fabi




More information about the Gcc-help mailing list