www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/02/10:48:35

Date: Wed, 2 Jul 1997 10:45:44 -0400 (EDT)
From: "Art S. Kagel" <kagel AT ns1 DOT bloomberg DOT com>
To: Pauli Saksa <ps AT traditor DOT fi>
Cc: djgpp AT delorie DOT com
Subject: Re: problems with void main(...)
In-Reply-To: <33B95552.7C88@traditor.fi>
Message-Id: <Pine.D-G.3.91.970702104214.19531A-100000@dg1>
Mime-Version: 1.0

On Tue, 1 Jul 1997, Pauli Saksa wrote:

> here's the source:
> 
> #include <stdio.h>
> void main(short argc)

First problem: main MUST ALWAYS RETURN AN int!  Second problem the first 
argument to main() is an int not a short!  Third, in general argc is 
pretty useless without argv so... main should be: 

int main( int argc, char **argv )

> {
>   printf("argc: %d", argc);
>   return;

Last problem, since the linker expects main to return an int your return 
MUST return something:

   return 0;

> }
> 
> and here's the compiler's messages:
> 
> In function `int main(...)':
> warning: `return' with no value, in function returning non-void

Art S. Kagel, kagel AT bloomberg DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019