Liste des Groupes | Revenir à cl c |
Thiago Adams <thiago.adams@gmail.com> writes:
>What is your opinion about this:>
>
unsigned int u1 = -1;
>
Generally -1 is used to get the maximum value.
Yes, that's a common usage, though I prefer either -1u or ~0u.
>Is this guaranteed to work?>
>
How about this one?
>
unsigned int u2 = -2;
Does it makes sense? Maybe a warning here?
Warnings are almost always good, especially if they can be configured.
For example you can ask gcc to warn about converting -1 to unsigned
while leaving -1u and ~0u alone.
Les messages affichés proviennent d'usenet.