I'm sure this is a stupid question, but I was wondering...

I noticed that in the avr-libc header <pgmspace.h> that there are declarations including:

extern size_t strlen_P(PGM_P) __ATTR_CONST__; /* program memory can't change */ extern size_t strnlen_P(PGM_P, size_t) __ATTR_CONST__; /* program memory can't change */

where __ATTR_CONST__ is defined as __attribute__((__const__))

Now, it says in the GCC 4.0 manual about function attributes in the section about "const" that:

--
const
Many functions do not examine any values except their arguments, and have no effects except the return value. Basically this is just slightly more strict class than the pure attribute below, since function is not allowed to read global memory.

Note that a function that has pointer arguments and examines the data pointed to must not be declared const. Likewise, a function that calls a non-const function usually must not be const. It does not make sense for a const function to return void.
--

Of course, strlen_P() *does* have pointer arguments, and *does* examine the data pointed to (though only in a read-only way).
Is it a problem that it is declared const, considering the above?

And if I was using the self-programming flash capabilities of the AVR would this be a problem?

--
Ned Konz
[EMAIL PROTECTED]




_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to