[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

Static identifier => not reserved

candide

7/12/2008 9:30:00 PM

The standard says :

----------------------------- 8< ----------------------------------
7.1.3 Reserved identifiers
[...]
? All identifiers with external linkage in any of the following
subclauses (including the future library directions) are always reserved
for use as identifiers with external linkage.

? Each identifier with file scope listed in any of the following
subclauses (including the future library directions) is reserved for use
as a macro name and as an identifier with file scope in the same name
space if any of its associated headers is included.
----------------------------- >8 ----------------------------------

Does this mean I'm allowed to give a STATIC function a name starting
with the str prefix ?

For instance, is the following code valid

------------- 8< ---------------
#include <stdio.h>

static size_t strlen(const char *s)
{
/* My own strlen() code */
}

int main(void)
{
printf("%lu\n",(unsigned long)strlen("blahblah"));

return 0;
}
------------- >8 ---------------

?


Thanks
2 Answers

gordonb.b3oxs

7/12/2008 11:53:00 PM

0

>----------------------------- 8< ----------------------------------
>7.1.3 Reserved identifiers
>[...]
>? All identifiers with external linkage in any of the following
>subclauses (including the future library directions) are always reserved
>for use as identifiers with external linkage.
>
>? Each identifier with file scope listed in any of the following
>subclauses (including the future library directions) is reserved for use
>as a macro name and as an identifier with file scope in the same name
>space if any of its associated headers is included.
>----------------------------- >8 ----------------------------------
>
>Does this mean I'm allowed to give a STATIC function a name starting
>with the str prefix ?

Not if you include <string.h>, in which case the second paragraph
above is an issue. Otherwise, it's OK.

>For instance, is the following code valid
>
>------------- 8< ---------------
>#include <stdio.h>
>
>static size_t strlen(const char *s)
>{
>/* My own strlen() code */
>}
>
>int main(void)
>{
> printf("%lu\n",(unsigned long)strlen("blahblah"));
>
> return 0;
>}
>------------- >8 ---------------
>
>?

It's OK, but I think it would be less confusing if you named it
something else.