1 | | RFC 68: C++11 Compilation Mode |
| 1 | = RFC 68: C++11 Compilation Mode = |
| 2 | |
| 3 | || Author: || Kurt Schwehr || |
| 4 | || Contact: || schwehr@google.com / schwehr@gmail.com || |
| 5 | || Started: || 2017-Apr-11 || |
| 6 | || Status: || '''Work-In-Progress''' || |
| 7 | |
| 8 | This RFC is based on trac.osgeo.org/geos/wiki/RFC5 GEOS RFC 5 |
| 9 | by Mateusz Łoskot. |
| 10 | |
| 11 | == Summary == |
| 12 | |
| 13 | The document proposes to switch to |
| 14 | en.wikipedia.org/wiki/C%2B%2B11 C++11 compilation mode as |
| 15 | default throughout the whole C++ source code of GDAL. |
| 16 | |
| 17 | The goal of the document is to request and achieve agreement on using |
| 18 | C++11 as the minimum required version of the C++ programming language |
| 19 | standard. |
| 20 | |
| 21 | == Motivation == |
| 22 | |
| 23 | The C++11 is the first major update of the C++ standard since 1998. (C++03 was a bug fix release.) |
| 24 | |
| 25 | The C++11 features aim to promote writing clean, compact, type-safe and fast code. It also delivers better feature-wise compatibility with C language (C99). |
| 26 | |
| 27 | The Wikipedia article at en.wikipedia.org/wiki/C++11 does a great job describing all changes in C++11 extensively. |
| 28 | |
| 29 | The `std::auto_ptr` smart pointer, together with a bunch of other features, has been deprecated and will be removed from C++17. |
| 30 | |
| 31 | The new compilers provide better diagnostics. |
| 32 | |
| 33 | Enabling C++11 compilation mode will improve the programming environment making it much friendlier than C++98. |
| 34 | |
| 35 | A social factor: since (many) C++ programmers no longer enjoy C++98, allowing C++11 mode may increase potential for new contributions. |
| 36 | |
| 37 | == Compilers Landscape == |
| 38 | |
| 39 | Summary of compilers supported by GDAL with their minimal versions |
| 40 | required to compile source code based on |
| 41 | en.cppreference.com/w/cpp/compiler_support C++11 features. |
| 42 | |
| 43 | === C++11 === |
| 44 | |
| 45 | ||GCC ||4.8.1+ ||[https://gcc.gnu.org/projects/cxx-status.html#cxx11 C++11 status] ||Debian 8 (stable), Ubuntu 15.04+, Ubuntu 14.04 `ppa:ubuntu-toolchain-r/test`, Fedora 19+, RHEL7 || |
| 46 | ||Clang||3.3+ ||[https://clang.llvm.org/cxx_status.html#cxx11 C++11 status] ||Debian 8 (stable), Ubuntu 14.04+, Fedora 19+, CentOS 6(?)|| |
| 47 | ||MSVC ||12.0+ (2013)||[https://msdn.microsoft.com/en-us/library/hh567368.aspx C++11 status]||n/a|| |
| 48 | |
| 49 | === C++14 === |
| 50 | |
| 51 | The C++14 compilers are listed for comparison only: |
| 52 | |
| 53 | ||GCC ||4.9+ || |
| 54 | ||Clang||3.4+ || |
| 55 | ||MSVC ||14.0+ (2015)|| |
| 56 | == Plan == |
| 57 | |
| 58 | This proposal only requests agreement for the C++11 compilation mode |
| 59 | switch in the current `trunk` branch only. |
| 60 | |
| 61 | If accepted, currently available build configurations (Autotools, |
| 62 | CMake, NMake) will be updated to switch the compilation mode to C++11. |
| 63 | |
| 64 | This proposal does not suggest any detailed roadmap of big refactoring |
| 65 | of the GDAL C++ codebase. |
| 66 | |
| 67 | The GDAL codebase is around 150 KLOC and given the available man-power |
| 68 | to LOCs ratio, such one-step refactoring would not be feasible. |
| 69 | |
| 70 | Instead, the task will be tackled with the baby step approach |
| 71 | gradually transforming the codebase according to priorities set along |
| 72 | the way. Any disruptive refactoring, changes in interfaces of C++ |
| 73 | classes, breaking changes in C++ API must be announced and discussed |
| 74 | on the mailing list or the bug tracker. |
| 75 | |
| 76 | '''IMPORTANT''': C++11 refactoring must not change the C API or break C |
| 77 | API compatibility, unless agreed upon based on prior RFC proposed. |
| 78 | |
| 79 | However, if the proposal is accepted, any new C++ code written for |
| 80 | GDAL can be C++11-compliant. |
| 81 | |
| 82 | Prior acceptance of this proposal is necessary in order to start any |
| 83 | source code refactoring using C++11 features. |
| 84 | |
| 85 | Once accepted, first step will be to update the build configurations |
| 86 | to require C++11-compliant compiler. |
| 87 | |
| 88 | == Issues == |
| 89 | |
| 90 | This section outlines issues potentially caused by upgrade to C++11 |
| 91 | language. |
| 92 | |
| 93 | * C++11 destructors, by default, have now the new exception |
| 94 | specification of `nothrow(true)`. Destructors of GDAL classes should |
| 95 | be reviewed and any that are allowed/expected to throw exceptions |
| 96 | must be marked with `nothrow(false)`. Otherwise, any user of the |
| 97 | existing GDAL codebase would find the program terminating whenever |
| 98 | GDAL destructor throws an exception. Such review would be beneficial |
| 99 | anyway. |
| 100 | |
| 101 | == Release == |
| 102 | |
| 103 | First release of GDAL with C++11 compiler requirement could be 2.3.0. |
| 104 | |
| 105 | === C++14 === |
| 106 | |
| 107 | This section clarifies status of C++14 support in GDAL. |
| 108 | |
| 109 | * Once C++11 is adopted as default compilation mode, GDAL developers |
| 110 | and maintainers must ensure it also successfully compiles in C++14 |
| 111 | and C++17 modes. |
| 112 | |
| 113 | * Are contributors allowed to add `ifdef`'s for C++14 and C++17? No. |
| 114 | |
| 115 | * Is there a plan to upgrade to C++14 or C++17 to allow use of the C++ |
| 116 | latest features? No, there is no plan. It is, however, recognized, |
| 117 | such motion may be put to the vote around 2020. |
| 118 | |
| 119 | == References == |
| 120 | |
| 121 | * en.cppreference.com/w/cpp/compiler_support C++ compiler support |
| 122 | |
| 123 | == Self-assigned development constraints == |
| 124 | |
| 125 | *TODO* |
| 126 | |
| 127 | The changes should have moderate impact on the existing GDAL/OGR code base, and |
| 128 | particularly on most of its code, that lies in drivers. |
| 129 | Existing users of the GDAL/OGR API should also be moderately impacted by the |
| 130 | changes, if they do not need to use the new offered capabilities. |
| 131 | |
| 132 | == Core changes: summary == |
| 133 | |
| 134 | '''TODO''' |
| 135 | |
| 136 | == Core changes: details == |
| 137 | |
| 138 | '''TODO''' |
| 139 | |
| 140 | * > > to >> |
| 141 | |
| 142 | === Other === |
| 143 | |
| 144 | '''TODO''' |
| 145 | |
| 146 | == Changes to Travis-CI == |
| 147 | |
| 148 | == Changes to AppVeyor == |
| 149 | |
| 150 | == Changes in drivers == |
| 151 | |
| 152 | '''TODO''' |
| 153 | |
| 154 | == Changes in utilities == |
| 155 | |
| 156 | '''TODO''' |
| 157 | |
| 158 | == Changes in SWIG bindings == |
| 159 | |
| 160 | '''TODO''' |
| 161 | |
| 162 | The switch does not impact the `C` API used by the SWIG bindings. |
| 163 | However, there may be some code that can be removed. |
| 164 | |
| 165 | * Python and Java bindings: |
| 166 | * Perl and CSharp: make sure that it still compiles but some work would have |
| 167 | |
| 168 | == Potential changes that are *NOT* included in this RFC == |
| 169 | |
| 170 | '''TODO''' |
| 171 | |
| 172 | "Natural" evolutions of current RFC : |
| 173 | |
| 174 | Further steps : |
| 175 | |
| 176 | == Backward compatibility == |
| 177 | |
| 178 | '''TODO''' |
| 179 | |
| 180 | == Documentation == |
| 181 | |
| 182 | '''TODO''' |
| 183 | |
| 184 | == Testing == |
| 185 | |
| 186 | '''TODO''' |
| 187 | |
| 188 | Very few changes have been made so that the existing autotest suite |
| 189 | still passes. Additions have been made to test the GDALOpenEx() API |
| 190 | and the methods "imported" from OGRDataSource into GDALDataset. |
| 191 | |
| 192 | == Version numbering == |
| 193 | |
| 194 | '''TODO''' |
| 195 | |
| 196 | Although the above describes changes should have very few impact on existing |
| 197 | applications of the C API, some behavior changes, C++ level changes and the |
| 198 | conceptual changes are thought to deserve a 2.3 version number. |
| 199 | |
| 200 | == Implementation == |
| 201 | |
| 202 | '''TODO''' |
| 203 | |
| 204 | Implementation will be done by Kurt Schwehr. |
| 205 | |
| 206 | == Related RFCs == |
| 207 | |
| 208 | '''TODO''' |
| 209 | |
| 210 | There are a few related past RFCs that have never been adopted but strongly |
| 211 | relate to RFC 68: |
| 212 | * trac.osgeo.org/geos/wiki/RFC5 GEOS RFC 5: C++11 Compilation Mode. |
| 213 | GEOS is switching to requiring C++11 to build. |
| 214 | |
| 215 | == Voting history == |
| 216 | |
| 217 | No vote taken yet. |