Can anyone point me to the definition of strlen() in GCC? I've been grepping release 4.4.2 for about a half hour now (while Googling like crazy) and I can't seem to find where strlen() is actually implemented.
shouldn't you look in source code of the appropriate library instead of GCC?
You should be looking in glibc, not GCC -- it seems to be defined in strlen.c
-- here's a link to strlen.c for glibc version 2.7... And here is a link to the glibc SVN repository online for strlen.c.
The reason you should be looking at glibc and not gcc is:
The GNU C library is used as the C library in the GNU system and most systems with the Linux kernel.
Is this what you are looking for? strlen() source. See the git repository for more information. The glibc resources page has links to the git repositories if you want to grab them rather than looking at the web view.
Here's the bsd implementation
size_t
strlen(const char *str)
{
const char *s;
for (s = str; *s; ++s)
;
return (s - str);
}
Google Code Search is a good starting point for questions like that. They usually point to various different sources and implementations of a function.
In your particular case: GoogleCodeSearch(strlen)