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
I realize this question is 4yrs old, but gcc will often include its own copy of strlen if you do not #include
and none of the answers (including the accepted answer) account for that. If you forget, you will get a warning:
file_name:line_number: warning: incompatible implicit declaration of built-in function 'strlen'
and gcc will inline its copy which on x86 is the repnz scasb asm variant unless you pass -Werror or -fno-builtin. The files related to this are in gcc/config/
It is also controlled by gcc/builtins.c. In case you wondered if and how a strlen() was optimized to a constant, see the function defined as tree c_strlen(tree src, int only_value)
in this file. It also controls how strlen (amongst others) is expanded and folded (based on the previously mentioned config/platform)