xref: /OK3568_Linux_fs/buildroot/package/duma/0003-fix-C++14.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyundumapp: fix for C++14
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunWith C++14, the way exceptions are specified has changed (somehow, don't
4*4882a593Smuzhiyunask me), thus causing build failures:
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun    dumapp.cpp: In function ‘void* operator new(std::size_t)’:
7*4882a593Smuzhiyun    dumapp.cpp:192:19: error: declaration of ‘void* operator new(std::size_t) throw (std::bad_alloc)’ has a different exception specifier
8*4882a593Smuzhiyun     void * DUMA_CDECL operator new( DUMA_SIZE_T size )
9*4882a593Smuzhiyun                       ^~~~~~~~
10*4882a593Smuzhiyun    In file included from dumapp.cpp:39:0:
11*4882a593Smuzhiyun    dumapp.h:91:23: note: from previous declaration ‘void* operator new(std::size_t)’
12*4882a593Smuzhiyun     void * DUMA_CDECL operator new(DUMA_SIZE_T) throw(std::bad_alloc);
13*4882a593Smuzhiyun                       ^~~~~~~~
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunThis is most evident with gcc-6.x, since the default C++ standard has
16*4882a593Smuzhiyunchanged from C++11 to C++14, thus exposing these new failures.
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunFix that by guarding the exception handling, a bit like was done
19*4882a593Smuzhiyunwith GRASS GIS (thanks DuckDuckGo):
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun    https://trac.osgeo.org/grass/changeset?old_path=%2F&old=68817&new_path=%2F&new=68818&sfp_email=&sfph_mail=
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunSigned-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun---
26*4882a593SmuzhiyunNote: The last commit in DUMA's CVS repo was more than 7 years ago.
27*4882a593SmuzhiyunI doubt it is still active, so the patch was not sent upstream. :-/
28*4882a593Smuzhiyun
29*4882a593Smuzhiyundiff -durN duma-2.5.15.orig/dumapp.cpp duma-2.5.15/dumapp.cpp
30*4882a593Smuzhiyun--- duma-2.5.15.orig/dumapp.cpp	2008-08-03 22:46:06.000000000 +0200
31*4882a593Smuzhiyun+++ duma-2.5.15/dumapp.cpp	2016-07-10 21:55:22.670386099 +0200
32*4882a593Smuzhiyun@@ -190,7 +190,9 @@
33*4882a593Smuzhiyun  * (11) = (a) ; ASW
34*4882a593Smuzhiyun  */
35*4882a593Smuzhiyun void * DUMA_CDECL operator new( DUMA_SIZE_T size )
36*4882a593Smuzhiyun+#ifdef DUMA_EXCEPTION_SPECS
37*4882a593Smuzhiyun throw(std::bad_alloc)
38*4882a593Smuzhiyun+#endif
39*4882a593Smuzhiyun {
40*4882a593Smuzhiyun   return duma_new_operator(size, EFA_NEW_ELEM, true  DUMA_PARAMS_UK);
41*4882a593Smuzhiyun }
42*4882a593Smuzhiyun@@ -254,7 +256,9 @@
43*4882a593Smuzhiyun  * (21) = (a) ; AAW
44*4882a593Smuzhiyun  */
45*4882a593Smuzhiyun void * DUMA_CDECL operator new[]( DUMA_SIZE_T size )
46*4882a593Smuzhiyun+#ifdef DUMA_EXCEPTION_SPECS
47*4882a593Smuzhiyun throw(std::bad_alloc)
48*4882a593Smuzhiyun+#endif
49*4882a593Smuzhiyun {
50*4882a593Smuzhiyun   return duma_new_operator(size, EFA_NEW_ARRAY, true  DUMA_PARAMS_UK);
51*4882a593Smuzhiyun }
52*4882a593Smuzhiyundiff -durN duma-2.5.15.orig/dumapp.h duma-2.5.15/dumapp.h
53*4882a593Smuzhiyun--- duma-2.5.15.orig/dumapp.h	2009-04-11 14:41:44.000000000 +0200
54*4882a593Smuzhiyun+++ duma-2.5.15/dumapp.h	2016-07-10 21:55:22.670386099 +0200
55*4882a593Smuzhiyun@@ -35,6 +35,10 @@
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun #include "duma.h"
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun+#if __cplusplus < 201103L
60*4882a593Smuzhiyun+  #define DUMA_EXCEPTION_SPECS 1
61*4882a593Smuzhiyun+#endif
62*4882a593Smuzhiyun+
63*4882a593Smuzhiyun /* remove previous macro definitions */
64*4882a593Smuzhiyun #include "noduma.h"
65*4882a593Smuzhiyun
66