"Peter Nilsson" <> wrote:
>"Jack Klein" <> wrote in message
>news:.. .
>>
>> On Sat, 26 Jun 2004 12:38:41 +1000, "Peter Nilsson"
>> <> wrote in comp.lang.c:
>>
>> > "Vijay Kumar R Zanvar" <> wrote in message
>> > news:...
>> > >
>> > > "CBFalconer" <> wrote in message
>> > > news:...
>> > > >
>> > > > In addition, names begining with "str" are reserved for the
>> > > > implementation. You should change those.
>> > >
>> > > IIRC, the restriction is not for the local variables. Please
>> > > correct me, if I understood it wrongly.
>> >
>> > See 7.1.3, 7.1.4 & 7.26
>> >
>> > Identifiers beginning with 'str' followed by at least one lower
>> > case letter are reserved for use as identifiers with external
>> > linkage. [In C90, such linkage is possibly case insensitive.]
>> > If <string.h> or <stdlib.h> is included, then they are reserved
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^
>> > as macro names and file scope identifiers too.
> ^^^^^^^^^^^^^^
>> >
>> > But it's still possible to declare a local (auto) variable and have
>> > problems...
>> >
>> > #include <string.h>
>> >
>> > void bar(int);
>> >
>> > void foo(void)
>> > {
>> > void (*strobe)(int) = bar; /* ok */
>> > strobe(42); /* UB */
>
>This is a function macro like application of a reserved identifier.
No. I can't find *any* macro defined in your code, for that matter.
What's disallowed is to write something like this:
#include <string.h>
#define strobe0 42 /* UB, str[a-z]* used as macro name */
static int strobe; /* UB, str[a-z]* used as file scope identifier */
whereas e.g. the following TU is valid:
/* Look Ma, no string.h included. */
#define strobe0 42
static int strobe;
as well as this one:
#include <string.h>
int foo( void )
{
int strstr = 666; /* Look Ma, block scope identifier. */
return strstr;
}
>> I disagree with your assessment. The fact that a block scoped pointer
>> object holds the name of something (function or object) with external
>> linkage does not violate the standard requirement above. ...
>
>It's the reserved use as a function macro which is the problem.
No. It's used as a simple block scope identifier, which is perfectly
fine (modulo it may shadow a 'strobe' identifier defined in some
future version of string.h, but that's the programmer's problem then,
and doesn't result in undefined behaviour a priori).
Regards
--
Irrwahn Grausewitz ()
welcome to clc:
http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list :
http://www.faqs.org/faqs/C-faq/faq/
clc OT guide :
http://benpfaff.org/writings/clc/off-topic.html