Edit:
I'm still wondering, sometimes my compiler (LLVM clang-1000.10.44.4) gives me an error instead of a warning, like if I try to initialize a variable like this
double d1 {34.56};
then it gives me an error that says
pr2.cc:6:11: error: expected ';' at end of declaration
double d1 {34.56};
^
;
But it doesn't give me a warning that its a C++11 extension (which I think it is). |
1. Use the newest version of the language that you have available to you. Use the -std=c++20 flag if you have it. Or c++17, 14 or 11.
2. An old version of the language (c++98 (aka c++9x), c++03) does not automatically know that certain constructs are newly added features ("extensions") in the next version. If someone were updating the c++03 compiler at the same time that early versions of the c++11 compiler were being implemented, new features may be flagged as extensions in the new version. Nothing requires old compilers to notice new compiler constructs and add them as warnings. In this case,
double d1 {34.56};
is not a valid c++03 construct, so it is an error. The old compiler does not have any responsibility to know that c++11 will accept this construct.
Oh, and this explains what you meant by "extensions" in you previous post. I took it to mean non-standard extensions provided by the compiler for historical support or a nice-to-have feature provided only by that compiler manufacturer. You meant new features added to the language in a soon-to-be-released standard. The term "extension" is ambiguous.
The way to get rid of soon-to-be-released extension warnings is to use a newer standard when compiling your code. That's it. If you see a warning like this, add the correct compile flag and compile again.
And VAR? I don't know. I made up that statement about work-related acronym to cover my shame of typing a completely wrong term. I may have had varargs or something similar in the back of my mind when I typed that. The takeaway is, I typed VAR when I meant VLA, you copied it, I realized my mistake when I read your post, and I wanted to make sure you were aware of the correct term.