Re: Possible ANSI C Optimisation Done in Practice?

Ralph Corderoy <ralph@inputplus.demon.co.uk>
15 Dec 2001 00:37:53 -0500

          From comp.compilers

Related articles
Possible ANSI C Optimisation Done in Practice? ralph@inputplus.demon.co.uk (2001-12-11)
Re: Possible ANSI C Optimisation Done in Practice? ralph@inputplus.demon.co.uk (Ralph Corderoy) (2001-12-15)
Re: Possible ANSI C Optimisation Done in Practice? rsherry8@home.com (Robert Sherry) (2001-12-15)
Re: Possible ANSI C Optimisation Done in Practice? rbates@southwind.net (Rodney M. Bates) (2001-12-15)
Re: Possible ANSI C Optimisation Done in Practice? nmm1@cus.cam.ac.uk (2001-12-19)
Re: Possible ANSI C Optimisation Done in Practice? ralph@inputplus.demon.co.uk (2001-12-20)
Re: Possible ANSI C Optimisation Done in Practice? ralph@inputplus.demon.co.uk (2001-12-20)
Re: Possible ANSI C Optimisation Done in Practice? ralph@inputplus.demon.co.uk (2001-12-20)
[12 later articles]
| List of all articles for this month |

From: Ralph Corderoy <ralph@inputplus.demon.co.uk>
Newsgroups: comp.compilers
Date: 15 Dec 2001 00:37:53 -0500
Organization: Compilers Central
References: 01-12-050 <200112120335.fBC3ZMg01140@budgie.cs.uwa.edu.au>
Keywords: optimize
Posted-Date: 15 Dec 2001 00:37:53 EST

Hi Chris,


> > #include <string.h>
> > ...
> > for (i = 0; i < strlen(s); i++) {
>
> Excuse my ignorance on this, but how does the compiler know what
> strlen() does? Does an ANSI C compiler *know* that strlen() does not
> have any side-effects, and/or can I not provide my own strlen()
> function in another source file, with very different semantics?


An ANSI C compiler does know the semantics of strlen if the compiler
writers have arranged for that to be the case. For instance, AIX's
<string.h> #defines strlen to be __strlen which the compiler recognises
as *the* standard strlen function.


Yes, you can define your own, although under AIX that would cause some
problems because of the #define. Note though, IIRC ANSI reserves all
function names beginning `str' so you're clashing with them.


Cheers,




Ralph.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.