On 27-6-2014 21:33, Jon A. Cruz wrote:
On Fri, Jun 27, 2014, at 12:03 PM, Tavmjong Bah wrote:
Hi,
I noticed a bunch of 'for' loops in Liam's code and that got me wondering about using C++11 in the experimental branch as 'auto' is so much nicer that "std::map<SPDocument*,int>::iterator iter". When can we start using C++11?
I noticed that http://wiki.inkscape.org/wiki/index.php/C%2B%2B11 only shows results for one Window's compiler. Is there a test program we can run? Fedora 20 is using GCC 4.8 and clang 3.4; both support 'auto' (GCC since 4.4).
Well... there are two different issues "start using C++ 11" and "require C++ 11".
We can start using it now. The main question is when to make it a requirement. (I've written lots of production code that compiles both with and without C++ 11 features)
You mean to #ifdef the hell out of it? I am very much against this. We already have this in our code, and it is terrible. For me "using C++11" means we require it, full stop.
The secondary question is *which* parts of C++ 11 we can require, and which we have to defer. I believe last time I checked things for the day job included versions of gcc had only about 40% C++ 11 coverage. We also will need to take care to differentiate between C++ 11 features that are present versus those that function correctly. :-)
So we'll need to add a chart of which compilers we need to stay compatible with. Then we can cross-reference with the Apache page and quickly update our chart.
This is what this page is about: http://wiki.inkscape.org/wiki/index.php/C%2B%2B11 On Windows, we can easily use gcc 4.9 with devlibs64, and I hope after release we can update devlibs 32bit to gcc 4.9 too (because of ABI compatibility issues, we are stuck at 4.6) . I agree we should be careful using too many C++11 features; notably the threading stuff (it's great, but needs checking if all platforms support it correctly).
For the record my computer is currently stuck with gcc 4.2.1 since the hardware itself (32-bit CPU) is limited to OSX 10.6 and that does not have newer.
I hope you realize that this is not really tenable for Inkscape to keep compatible with such old compilers... (7 years is not that old in human terms, but it is a lot in computer terms)
With the current pace of development, any code one writes now will live for a long time. Therefore, I feel it is important we make the switch to C++11 asap.
- Johan