3 ms·
Please always use "-std=c++14" when you can. There are a lot of subtle differences between c++11 and c++14.
by c_shu 10y ago
Please always use "-std=c++14" when you can. There are a lot of subtle differences between c++11 and c++14.
- delhanty 10y agoOff-topic (apologies): From Xcode, I have the choice between "-std=c++14" and "-std=gnu++14" and I am not sure which I should choose ...
- Ralith 10y agoDo you want GNU extensions? Use the latter. Otherwise, use the former.
- CJefferson 10y agoGnu++14. This is because historically GCC / clang used gnu++03, so some libraries might require it. The gnu bit means "add as small number of extensions". None of them are that strange.
- kryptiskt 10y agoUse "-std=c++14" unless you need the gnu extensions for it to build, that ensures that you don't accidentally introduce non-portable code.
- nullc 10y agoThat is a nightmare fuel comment-- are people's valid C++11 codebases going to execute in materially different ways when someone flips the std flag to c++14?
- c_shu 10y agoYou have a point. Some people still write C++03 code because "My code will mostly work fine when I flip flag to C++11 anyway". But I always hope newer standards prevail, and make C++ great again.
- adrianN 10y agoAnd the people who program most of the stuff you can touch with your hands mostly still write c++-kinda-98 because "My compiler doesn't have a flag to flip to C++11 anyway" :(
- blub 10y agoI think "subtle differences" should read "subtle improvements" above. No nightmares to be expected :)
- daly 10y agoIt seems that the change from C++11 to C++14 broke the semantics of "inline". I'm not sure who thought that was a good idea. You'll find that code that used to compile no longer does. Reverse-engineering the failure all the back to the language specification is VERY time consuming. Finding the right compiler switch (--std) will also take a while, assuming you even know there IS such a compiler switch. It also seems (I might be wrong) that gcc defaults to C++11 but g++ defaults to C++14. Breaking legacy code without access to the original authors makes maintaining that code extremely difficult. Can you rewrite all of the "inline" instances in a 1M line C++ program without side-effects such as performance loss? When the lead programmer requires C++17 for their spiffy new code, are you the person who has to rewrite the "broken legacy code"? Does your IDE know all of the standards? They should change the language name each time, such as "Alpha", "Beta", "Gamma", etc. so you can say that you "know" the "Beta" language. As it is I don't know anyone who can seriously claim to know "C++". "C++ Standard" is an oxymoron.
- marvy 10y agoI find this odd; surely that shouldn't happen.
- 72deluxe 10y agoI find it easier to ask what standard they work to. If someone says "I write C++", I would ask "what version?" as there is a significant gulf between 2003 and 2011 standards, for example. Or, as is very common, they are not sure and it you will know that they don't know enough C++, or are in danger of writing C++ like it was C. If someone says "I play the guitar" and you ask "acoustic, electric? hollow bodied?" and they don't know, you'd be surprised. If someone says "I own a Volkswagen Golf" and you asked what mark (4, 5, 6 or 7) and they didn't know, you'd assume they knew nothing about they car or didn't have to replace any parts on it, even simple things like windscreen wipers as they'd have bought the wrong ones. It's the same with C++ - the spec makes a huge difference so we should probably all be aware of what we're writing.
- JoeAltmaier 10y ago....or, they look up in the manual when they have to change the wiper blades.
- wyldfire 10y agoYes. This is just like it did from 98 to 03, 03 to 11 and like it will be from 14 to 17. Don't worry, the standards team hates backwards incompatibility so they try really hard to minimize these differences. But here's a notorious case to the contrary [1]. [1] http://stackoverflow.com/a/620402/489590 http://stackoverflow.com/a/620402/489590