Keith Thompson wrote:
Richard Bos wrote:
Also _because_ it is so easy to write yourself.
Too bad you're not allowed to call it "strdup" if you #include
<string.h>
*Shrug* Call it str_dup() and #define strdup str_dup, then.
That's legal.
No it isn't.
Yes, it is. C99 7.26.11, under "Future library directions":
Function names that begin with str, mem, or wcs and a lowercase
letter may be added to the declarations in the <string.h> header.
No it isn't. See:
7.1.3 Reserved identifiers
[#1] Each header declares or defines all identifiers listed
in its associated subclause, and optionally declares or
defines identifiers listed in its associated future library
directions subclause and identifiers which are always
reserved either for any use or for use as file scope
identifiers.
... snip ...
-- 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.143)
Is the str_dup() function or the strdup macro that you're saying is
illegal?
str_dup is not a reserved identifier; it doesn't begin with str
and a lowercase letter.
strdup, if defined as a macro, doesn't have external linkage (though
you might need a "#undef strdup" if you've included <string.h>).