Require C++14
ClosedPublic

Authored by graesslin on Jul 11 2017, 6:31 PM.

Details

Reviewers
lbeltrame
ivan
Group Reviewers
Plasma
Commits
R108:ea5d611de1bc: Require C++14
Summary

KWin already used C++14 constructs in a conditional way. This doesn't
make much sense today, it's better to just require C++14.

For KWin only gcc and clang are currently compilers of relevance. Gcc
supports C++14 since version 5 and defaults to C++14 since 6.1 [1].
Clang supports C++14 since version 3.4 [2].

An overview of compiler support in various distributions:

  • Debian stable (stretch): gcc 6.3, clang 3.8
  • Debian oldstable (jessie): 4.9, clang 3.5
  • Ubuntu 17.04: gcc 6.1, clang 3.8
  • Ubuntu 16.04: gcc 5.3, clang 3.8
  • openSUSE Tumbleweed: gcc 7.1, clang 4.0
  • openSUSE Leap 42.3: gcc ?, clang ? [3]
  • FreeBSD: clang >= 34 in ports
  • Slackware 14.2: gcc 5.3

This overview shows that every distro out there has at least one
supported compiler which can still compile KWin with this change.

[1] https://gcc.gnu.org/projects/cxx-status.html#cxx14
[2] https://clang.llvm.org/cxx_status
[3] Sorry I fail to understand openSUSE's package repository.

It seems that there is gcc 7 available, but gcc package is 4.8
Test Plan

Compiles on my neon system

Diff Detail

Repository
R108 KWin
Branch
cxx-14
Lint
No Linters Available
Unit
No Unit Test Coverage
graesslin created this revision.Jul 11 2017, 6:31 PM
Restricted Application added a project: KWin. · View Herald TranscriptJul 11 2017, 6:31 PM
Restricted Application added subscribers: KWin, kwin, plasma-devel. · View Herald Transcript
ivan requested changes to this revision.Jul 11 2017, 8:22 PM
ivan added a subscriber: ivan.

It is undefined behaviour to extend std:: namespace in this way. You should go for this instead:

#if ...
    template ... make_unique ...
#else
    using std::make_unique;
#endif

p.s. Another potential problem is that it might happen that a compiler supports a core language from C++XX while the library implementation is behind. But I guess most platforms use libstdc++/gcc so that might not be a problem for kwin.

This revision now requires changes to proceed.Jul 11 2017, 8:22 PM
ivan accepted this revision.Jul 11 2017, 8:29 PM

Ignore my comment above, I'm colour-blind today :D

This revision is now accepted and ready to land.Jul 11 2017, 8:29 PM
lbeltrame edited edge metadata.Jul 13 2017, 10:07 AM

openSUSE Leap 42.3 uses GCC 4.8 as default, although 5 and 6 are available as well.

openSUSE Leap 42.3 uses GCC 4.8 as default, although 5 and 6 are available as well.

@lbeltrame does it mean it would create problems for openSUSE or would it be fine?

fvogt added a subscriber: fvogt.Jul 13 2017, 7:24 PM

openSUSE Leap 42.3 uses GCC 4.8 as default, although 5 and 6 are available as well.

@lbeltrame does it mean it would create problems for openSUSE or would it be fine?

It would be fine.

GCC 4.8 is the system compiler, which means it's used by default and used to compile the vast majority of packages
(it's the only compiler available in the base SLE, so packages coming from there, like Qt, are always built with it).
Leap 42.1 has additionally GCC 5, 42.2 got GCC 6 in plus and 42.3 will get GCC 7 as well.
It's just a matter of setting the CC/CXX variables correctly as they're configured to be ABI compatible (--with-default-libstdcxx-abi=gcc4-compatible -> std::string with CoW...).

This revision was automatically updated to reflect the committed changes.