Date: Wed, 19 Jun 1996 07:38:54 +0200 (IST) From: Eli Zaretskii To: Erik Max Francis Cc: djgpp AT delorie DOT com Subject: Re: Random numbers ... In-Reply-To: <31C6B9D7.22A82DEE@alcyone.com> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 18 Jun 1996, Erik Max Francis wrote: > Pretty simple solution: random is not an ANSI C function and is not available > in any DJGPP libraries. `random' indeed is non-ANSI, but DJGPP v2 *does* have it. Please, people, before you post such easy-to-verify statements, take a second and look into libc.inf index. > Johan De Messemaeker wrote: > > > I'm trying to port my old Borland-progs to the DJGPP compiler. > > But there's a line i can't figure out : > > > > int tmp; > > tmp = random(3); > > > > With Borland, no problemo, it compiles, with DJGPP version 2, nope ... The reason that the code above won't compile with DJGPP is that `random', being a non-standard function, does different things in BC and DJGPP: in BC random(3) returns a random integer between 0 and 3, whereas in DJGPP `random' doesn't expect to get any parameters and always returns a random number in the 0..MAXINT range. So GCC sees its prototype in saying this: long random(void); and refuses to compile the above code. Btw, it's always better to post the error message(s) that GCC prints when you say ``the code won't compile'', because sometimes it's very hard to guess what that message might be without actually recompiling the fragment.