Liste des Groupes | Revenir à cl c |
On 19/10/2024 17:18, Thiago Adams wrote:Em 10/18/2024 8:54 PM, Keith Thompson escreveu:>Thiago Adams <thiago.adams@gmail.com> writes:If not, do you have a sample where, using "const" as "constexpr",I think constexpr keyword is unnecessary.>
Sure, most language features are strictly unnecessary.
>Anything you do with it could/should be done with const.>
No, absolutely not.
>
would create problems?
The sample I know is VLA.
const int c = 2;
int a[c]; //a is VLA because c is not a constant expression.
But this is not enough to convince me because it is better not to be
a VLA here.
What practical difference would it make? Can you think of any
difference between local variables "a" and "b" defined like this?
>
enum { n = 2 };
const int c = n;
int a[c];
int b[n];
>
Can you show any situation where you could use "a" and not "b", or
vice versa, or where the meaning would be different? Can you show any
compiler that treats them differently in code generation (assuming a
compiler that supports enough of C99 to allow it)?
>
I know of no differences there. That is enough to convince me that it
doesn't matter in the slightest whether it is technically a VLA or
not.
Les messages affichés proviennent d'usenet.