Date: Tue, 11 Nov 1997 17:03:00 +0200 (IST) From: Eli Zaretskii To: Ove Kaaven cc: djgpp AT delorie DOT com Subject: Re: rand() or random() In-Reply-To: <3466e64d.9875734@news.arcticnet.no> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Mon, 10 Nov 1997, Ove Kaaven wrote: > Well, those copyright issues seem somewhat confusing. > Let's see... how legal is this implementation? > > int rand(void) > { > return random(); > } This is perfectly legal, but it breaks the ANSI Standard ruling that a standard C library is not allowed to use any global symbols except those reserved by the standard functions. In the case above, if an ANSI-standard program will call `rand', it will pull `random' from the library. This might mean grave problems and subtle bugs if that program defines its own function named `random'. The bugs will be even more subtle and catastrophic if the program defines a global variable named `random' (the linker will bravely resolve them both to the same address). Bottom line: an ANSI function cannot call non-ANSI functions unless their names begin with an underscore (ANSI explicitly reserves all such names in the global scope, so an application should not use them).