Liste des Groupes | Revenir à cl c |
On 8/2/24 14:42, Richard Damon wrote:Depends on the library and how many times it is used. It may be a perfectly safe call, as the function is defined not to change its parameter, but being external code the signature might not be fixable.On 8/2/24 2:24 PM, Keith Thompson wrote:...Richard Harnden <richard.nospam@gmail.invalid> writes:
[...]Is there any reason not to always write ...
>
static const char *s = "hello, world";
>
... ?...There's no good reason not to use "const". (If string literal objects
were const, you'd have to use "const" here.)The one good reason to not make it const is that if you are passing itActually, that's not a good reason. If you can't modify the function's
to functions that take (non-const) char* parameters that don't
actually change that parameters contents.
interface, you should use a (char*) cast, which will serve to remind
future programmers that this is a dangerous function call. You shouldn't
make the pointer's own type "char *".
Les messages affichés proviennent d'usenet.