FreeOrion

Forums for the FreeOrion project
It is currently Mon Dec 18, 2017 5:08 am

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: C++11
PostPosted: Sat Mar 26, 2016 3:29 pm 
Offline
Programmer

Joined: Mon Feb 29, 2016 8:37 pm
Posts: 205
I tried to search the forums for this topic, but C++11 is too short of a search term.

The question is.

Are we interested in starting to use C++11 features?

The more leading question is.

When will we be interested in using C++11 features?

I am bringing up this topic, mostly because I want to use the type inference of auto and the
automatic iteration of the new for loops.

Obviously, if the minimum versions of the compilers that we support do not support any features
of C++11 then this is a non-starter.

I think that the OSs/compilers that we are supporting are Apple/Clang(XCode), Linux/GCC, and Windows/MSVC.
I don't know what minimum versions of those compilers that we support.

The linked table shows C++ support in various compilers by version.
All C++11 features are supported by Clang 3.3, GCC 4.8.1 and MSVC 14.0.
Most features are supported by Clang 3.1, GCC 4.6, and MSVC 12.0.
Current compilers versions are Clang 3.8, GCC 5.3, and MSVC 14.0.

http://en.cppreference.com/w/cpp/compiler_support

C++11 features can simplify code for reading, improve performance and increase robustness.

The auto keyword, constexpr, ranged-for loop and initializer lists
all trivially improve readability and ease of writing.

Lambda expression can reduce verbosity in the code, depending on programmer use.

Rvalue references could improve performance
, depending on the extent of copy construction in the code.

Smart pointers, unique_ptr, shared_ptr and weak_ptr
are the new standard library versions of the same
from the Boost library.

This doesn't have to be an all or nothing change.
We could take individual features piecemeal and list
them on the compilation page as freeorion acceptable C++11 constructs.


Top
 Profile  
 
 Post subject: Re: C++11
PostPosted: Sat Mar 26, 2016 5:25 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
I think Vezzra has been unable to get a version of XCode that supports C++ to build FreeOrion, which has prevented any attempts to start using it.


Top
 Profile  
 
 Post subject: Re: C++11
PostPosted: Sat Mar 26, 2016 6:17 pm 
Offline
Release Manager, Design
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 4309
Location: Sol III
The problem is not that the version of Xcode I'm using (and the version of clang that comes with it) doesn't support C++11, but that my last attempts at building FO with C++11 enabled failed. Curiously enough, I've been able to do that already some time ago (two or three years, don't remember) on a try. We weren't considering doing that switch back then, and as doing it on OSX also means to give up compatibility with 10.6, I didn't pursue this further of course.

When the issue came up again (some time later), I tried again building with C++11 enabled, but failed. No one really pressed for the change, so again I dropped it. However, if the team wants to make the switch now, I can of course try again. Given the past experiences I expect that to be a considerable effort, so I'd have to prioritize this and put everything else on hold. And of course, I can't make any promises that I'll succeed, I'm not really an expert on these things. The C++ coding side has never been my strong suit, and unfortunately I'm the one and only Mac coder around here (AFAIK).


Top
 Profile  
 
 Post subject: Re: C++11
PostPosted: Sat Mar 26, 2016 7:40 pm 
Offline
Programmer

Joined: Mon Feb 29, 2016 8:37 pm
Posts: 205
That surprises me. I thought Xcode/Clang C++11 support was solid.

Do you mean that freeorion could not be compiled on 10.6 or that it could not even
be compiled for 10.6 on another OSX machine when using C++11?

Are the issues with 10.6 still a problem, is it still in common use?
I don't know the distribution of OSX versions in the wild or how aggressively Apple upgrades them.

Were your problems getting C++11 to work with the compiler Clang or with project files Xcode?

If your problems were with Clang then I could try to cross-compile with Clang
by hacking the CMakefiles and fix the Clang issues in the code. Unlikely, but I'd try.


Top
 Profile  
 
 Post subject: Re: C++11
PostPosted: Sat Mar 26, 2016 8:50 pm 
Offline
Programmer
User avatar

Joined: Fri Mar 01, 2013 9:52 am
Posts: 1040
Location: Germany
Quote:
Were your problems getting C++11 to work with the compiler Clang or with project files Xcode? […]
Unlikely, but I'd try.


It's probably the project setup.

No need to waste your time with testing the CMake build. I just build it and will push a new introduced issue in a few minutes.

Also when Vezzra talked about 'last time' we're talking about a time frame from around 2 years. Nobody cared enough for C++11 during that time to pester him for an updated project. Also we supported MSVC 2010 during that time which only has minimal C++11 support.

_________________
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz


Top
 Profile  
 
 Post subject: Re: C++11
PostPosted: Mon Mar 28, 2016 11:42 am 
Offline
Release Manager, Design
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 4309
Location: Sol III
LGM-Doyle wrote:
That surprises me. I thought Xcode/Clang C++11 support was solid.
It is, as far as I can tell. Like I said, I already have been able to build FO with C++11 features enabled, I just failed to reproduce this success.
Quote:
Do you mean that freeorion could not be compiled on 10.6 or that it could not even
be compiled for 10.6 on another OSX machine when using C++11?
The latter. I've already been on 10.8/10.10 when I tried to build with C++11, when I try to do that and set the min target OSX version to 10.6, I get an explicit error message stating that for C++11 the min target OSX version is 10.7.
Quote:
Are the issues with 10.6 still a problem, is it still in common use?
No, that's not an issue anymore. Two, three years ago this was a different story, 10.6 wasn't that outdated at the time, and dropping support for it was something I tried to avoid if possible.
Quote:
Were your problems getting C++11 to work with the compiler Clang or with project files Xcode?
I can't really tell that apart (I guess it's the latter), as I never build on the command line, invoking clang directly, I always build using Xcode. I guess that on my later, unsuccessful tries I must have failed to reproduce all the settings I apparently got right on my earlier, successful attempts.

The problem is that I don't really know what I'm doing. I'm not the one who set up the Xcode project, when I began contributing to FO (in late 2011) it was already there, but was somehow broken. Two guys were working on it to fix it, but were stuck. I then tried a few things, and, mostly by trial and error, got it working. There is probably a ton of legacy settings and other stuff you could remove, but as I said, not knowing what you're doing doesn't really help with that.

I've been maintaining the Xcode project ever since, but it's a bit of a fragile thing. It's more like keeping something running and hoping that nothing too serious breaks, because I might not be able to fix it.

Now, with all that in mind, just imagine me trying to make all the right adjustments to get FO building with C++11. I hope that this gives you a better idea of what the actual challenges of switching to C++11 on OSX are... ;)


Top
 Profile  
 
 Post subject: Re: C++11
PostPosted: Fri May 06, 2016 7:16 pm 
Offline
Programmer

Joined: Mon Feb 29, 2016 8:37 pm
Posts: 205
Vezzra, I am being pushy with the C++11 transition because I am concerned that you will leave for vacation and C++11 adoption will also be pushed into the fall timeframe. I'm also hoping to be lucky and that you try the new PR I pushed and it just works, or the errors are obvious to someone here.

The release is the more important issue, so please ignore my request if you think it too much.


Top
 Profile  
 
 Post subject: Re: C++11
PostPosted: Fri May 06, 2016 10:11 pm 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
Probably quickly earning an 'ignore anything he says' tag, but may be a conflict with using override to test, since it is already used in AIFramework.h and ServerFramework.h?

_________________
Any content posted should be considered licensed GNU GPL 2.0 and/or CC-BY-SA 3.0 as appropriate.


Top
 Profile  
 
 Post subject: Re: C++11
PostPosted: Sat May 07, 2016 7:36 pm 
Offline
Release Manager, Design
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 4309
Location: Sol III
LGM-Doyle wrote:
Vezzra, I am being pushy with the C++11 transition because I am concerned that you will leave for vacation and C++11 adoption will also be pushed into the fall timeframe.
A valid concern. ;)
Quote:
I'm also hoping to be lucky and that you try the new PR I pushed and it just works, or the errors are obvious to someone here.
You are lucky, and I did try, alas, it didn't just work. See my reply in the discussion thread of your PR. Doesn't look to bad though, there is only one issue I couldn't solve myself, and I'm hopeful that someone can help me out with that template/iterator/operator stuff that apparently is the problem here.
Quote:
The release is the more important issue, so please ignore my request if you think it too much.
Trying to build and posting build errors is manageable. :)


Top
 Profile  
 
 Post subject: Re: C++11
PostPosted: Sat May 07, 2016 7:42 pm 
Offline
Release Manager, Design
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 4309
Location: Sol III
dbenage-cx wrote:
Probably quickly earning an 'ignore anything he says' tag, but may be a conflict with using override to test, since it is already used in AIFramework.h and ServerFramework.h?
Ah yes, that's not really a problem so far. Just stupid me using the "override" directive in those locations without knowing that this is a C++11 feature. However, clang on OSX just gives a warning and ignores the statement, so I didn't bother to remove those uses of "override".


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group