www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/17/19:56:06

From: nikki AT gameboutique DOT co (nikki)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: weird gcc thing
Date: 17 Feb 1997 21:34:58 GMT
Organization: GameBoutique Ltd.
Lines: 38
Message-ID: <5eaiu2$j08@flex.uunet.pipex.com>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 970216133807 DOT 15715E-100000 AT is>
NNTP-Posting-Host: www.gameboutique.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> Did you actually gave 2 arguments to your program?  argv[0] is the 
> program name, argv[1] is the first argument.

yep :) this code compiled fine under unix and linux, i was porting it you see.
i managed to find something that exhibits this behavior...

void main(int argc,char *argv[])
{
	printf("%f but should be %s\n",atof(argv[1]),argv[1]);
}

save as test.c and compile gcc test.c -o test

now do test 8
it gives :

1.00000 should be 8

under linux and sunos it gives the correct value 8 however.

i eventually figured this one out, it can be solved by ensuring a #include
<stdlib.h> presumably linux and sunos were doing this automatically or
something. but it struck me as weird behavior nonetheless, after all it
compiled fine (ok -Wall would say implicit declaration, but you can do that
with printf in the example above and printf has the correct behavior?)

regards,
nik



> 
> If the above doesn't give a clue, post the shortest program you can craft 
> that exhibits this bug and the command line you pass it.

-- 
Graham Tootell           
nikki AT gameboutique DOT com  

- Raw text -


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