diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-12-18 20:58:28 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-12-26 10:08:53 +0100 |
| commit | 93d8f3a3504c1e92333524aa6aeca169c103166a (patch) | |
| tree | d227a8fe3df6e4d8190a2def84fb6aaedcd72c02 | |
| parent | 610957f7035242f15743c399ffd429b92bc36206 (diff) | |
| download | PROJ-93d8f3a3504c1e92333524aa6aeca169c103166a.tar.gz PROJ-93d8f3a3504c1e92333524aa6aeca169c103166a.zip | |
cpp conversion: fix One-Definition-Rule violations
Defining struct pj_opaque with different definitions is a violation
of the C++ One-Definition-Rule. When using link-time optimizations, this
could break badly.
The solution adopted here is to wrap those structures into a C++
anonymous namespace so they are considered different
82 files changed, 217 insertions, 11 deletions
diff --git a/src/PJ_aea.cpp b/src/PJ_aea.cpp index e4d1dc4f..88929e3b 100644 --- a/src/PJ_aea.cpp +++ b/src/PJ_aea.cpp @@ -67,6 +67,7 @@ static double phi1_(double qs, double Te, double Tone_es) { } +namespace { // anonymous namespace struct pj_opaque { double ec; double n; @@ -80,6 +81,7 @@ struct pj_opaque { double *en; int ellips; }; +} // anonymous namespace static PJ *destructor (PJ *P, int errlev) { /* Destructor */ diff --git a/src/PJ_aeqd.cpp b/src/PJ_aeqd.cpp index 72c7ae95..69bb76c3 100644 --- a/src/PJ_aeqd.cpp +++ b/src/PJ_aeqd.cpp @@ -32,13 +32,16 @@ #include "projects.h" #include "proj_math.h" +namespace { // anonymous namespace enum Mode { N_POLE = 0, S_POLE = 1, EQUIT = 2, OBLIQ = 3 }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque { double sinph0; double cosph0; @@ -51,6 +54,7 @@ struct pj_opaque { enum Mode mode; struct geod_geodesic g; }; +} // anonymous namespace PROJ_HEAD(aeqd, "Azimuthal Equidistant") "\n\tAzi, Sph&Ell\n\tlat_0 guam"; diff --git a/src/PJ_affine.cpp b/src/PJ_affine.cpp index b8fa4c68..c53d4e60 100644 --- a/src/PJ_affine.cpp +++ b/src/PJ_affine.cpp @@ -32,6 +32,7 @@ PROJ_HEAD(affine, "Affine transformation"); PROJ_HEAD(geogoffset, "Geographic Offset"); +namespace { // anonymous namespace struct pj_affine_coeffs { double s11; double s12; @@ -44,7 +45,9 @@ struct pj_affine_coeffs { double s33; double tscale; }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque_affine { double xoff; double yoff; @@ -53,6 +56,7 @@ struct pj_opaque_affine { struct pj_affine_coeffs forward; struct pj_affine_coeffs reverse; }; +} // anonymous namespace static PJ_COORD forward_4d(PJ_COORD obs, PJ *P) { diff --git a/src/PJ_airy.cpp b/src/PJ_airy.cpp index 037362b3..fa159bae 100644 --- a/src/PJ_airy.cpp +++ b/src/PJ_airy.cpp @@ -34,13 +34,16 @@ PROJ_HEAD(airy, "Airy") "\n\tMisc Sph, no inv\n\tno_cut lat_b="; +namespace { // anonymous namespace enum Mode { N_POLE = 0, S_POLE = 1, EQUIT = 2, OBLIQ = 3 }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque { double p_halfpi; double sinph0; @@ -49,6 +52,7 @@ struct pj_opaque { enum Mode mode; int no_cut; /* do not cut at hemisphere limit */ }; +} // anonymous namespace # define EPS 1.e-10 diff --git a/src/PJ_aitoff.cpp b/src/PJ_aitoff.cpp index 1af75469..ba1402a4 100644 --- a/src/PJ_aitoff.cpp +++ b/src/PJ_aitoff.cpp @@ -37,15 +37,19 @@ #include "projects.h" +namespace { // anonymous namespace enum Mode { AITOFF = 0, WINKEL_TRIPEL = 1 }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque { double cosphi1; enum Mode mode; }; +} // anonymous namespace PROJ_HEAD(aitoff, "Aitoff") "\n\tMisc Sph"; diff --git a/src/PJ_axisswap.cpp b/src/PJ_axisswap.cpp index d21eddb1..69edac8b 100644 --- a/src/PJ_axisswap.cpp +++ b/src/PJ_axisswap.cpp @@ -62,10 +62,12 @@ operation: PROJ_HEAD(axisswap, "Axis ordering"); +namespace { // anonymous namespace struct pj_opaque { unsigned int axis[4]; int sign[4]; }; +} // anonymous namespace static int sign(int x) { return (x > 0) - (x < 0); diff --git a/src/PJ_bacon.cpp b/src/PJ_bacon.cpp index f995e420..b00e1523 100644 --- a/src/PJ_bacon.cpp +++ b/src/PJ_bacon.cpp @@ -7,10 +7,12 @@ #include "projects.h" +namespace { // anonymous namespace struct pj_opaque { int bacn; int ortl; }; +} // anonymous namespace PROJ_HEAD(apian, "Apian Globular I") "\n\tMisc Sph, no inv"; PROJ_HEAD(ortel, "Ortelius Oval") "\n\tMisc Sph, no inv"; diff --git a/src/PJ_bertin1953.cpp b/src/PJ_bertin1953.cpp index 46420314..a551a6b2 100644 --- a/src/PJ_bertin1953.cpp +++ b/src/PJ_bertin1953.cpp @@ -21,9 +21,11 @@ PROJ_HEAD(bertin1953, "Bertin 1953") "\n\tMisc Sph no inv."; +namespace { // anonymous namespace struct pj_opaque { double cos_delta_phi, sin_delta_phi, cos_delta_gamma, sin_delta_gamma, deltaLambda; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { diff --git a/src/PJ_bipc.cpp b/src/PJ_bipc.cpp index 243ecccd..95cbcbb8 100644 --- a/src/PJ_bipc.cpp +++ b/src/PJ_bipc.cpp @@ -29,9 +29,11 @@ PROJ_HEAD(bipc, "Bipolar conic of western hemisphere") "\n\tConic Sph"; # define R104 1.81514242207410275904 +namespace { // anonymous namespace struct pj_opaque { int noskew; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_bonne.cpp b/src/PJ_bonne.cpp index 6c51af7c..0e979f64 100644 --- a/src/PJ_bonne.cpp +++ b/src/PJ_bonne.cpp @@ -9,6 +9,7 @@ PROJ_HEAD(bonne, "Bonne (Werner lat_1=90)") "\n\tConic Sph&Ell\n\tlat_1="; #define EPS10 1e-10 +namespace { // anonymous namespace struct pj_opaque { double phi1; double cphi1; @@ -16,6 +17,7 @@ struct pj_opaque { double m1; double *en; }; +} // anonymous namespace static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */ diff --git a/src/PJ_cass.cpp b/src/PJ_cass.cpp index cc610940..2488f405 100644 --- a/src/PJ_cass.cpp +++ b/src/PJ_cass.cpp @@ -15,10 +15,12 @@ PROJ_HEAD(cass, "Cassini") "\n\tCyl, Sph&Ell"; # define C5 .06666666666666666666 +namespace { // anonymous namespace struct pj_opaque { double *en; double m0; }; +} // anonymous namespace diff --git a/src/PJ_ccon.cpp b/src/PJ_ccon.cpp index 6ff2d3b1..4ee53133 100644 --- a/src/PJ_ccon.cpp +++ b/src/PJ_ccon.cpp @@ -28,6 +28,7 @@ #define EPS10 1e-10 +namespace { // anonymous namespace struct pj_opaque { double phi1; double ctgphi1; @@ -35,6 +36,7 @@ struct pj_opaque { double cosphi1; double *en; }; +} // anonymous namespace PROJ_HEAD(ccon, "Central Conic") "\n\tCentral Conic, Sph\n\tlat_1="; diff --git a/src/PJ_cea.cpp b/src/PJ_cea.cpp index ee7eebf5..3c9e128d 100644 --- a/src/PJ_cea.cpp +++ b/src/PJ_cea.cpp @@ -6,10 +6,12 @@ #include "proj.h" #include "projects.h" +namespace { // anonymous namespace struct pj_opaque { double qp; double *apa; }; +} // anonymous namespace PROJ_HEAD(cea, "Equal Area Cylindrical") "\n\tCyl, Sph&Ell\n\tlat_ts="; # define EPS 1e-10 diff --git a/src/PJ_chamb.cpp b/src/PJ_chamb.cpp index 8d8f05ee..0da3899b 100644 --- a/src/PJ_chamb.cpp +++ b/src/PJ_chamb.cpp @@ -7,6 +7,7 @@ #include "projects.h" typedef struct { double r, Az; } VECT; +namespace { // anonymous namespace struct pj_opaque { struct { /* control point data */ double phi, lam; @@ -18,6 +19,7 @@ struct pj_opaque { XY p; double beta_0, beta_1, beta_2; }; +} // anonymous namespace PROJ_HEAD(chamb, "Chamberlin Trimetric") "\n\tMisc Sph, no inv" "\n\tlat_1= lon_1= lat_2= lon_2= lat_3= lon_3="; diff --git a/src/PJ_deformation.cpp b/src/PJ_deformation.cpp index 1398f5fd..49f62c01 100644 --- a/src/PJ_deformation.cpp +++ b/src/PJ_deformation.cpp @@ -63,11 +63,13 @@ PROJ_HEAD(deformation, "Kinematic grid shift"); #define TOL 1e-8 #define MAX_ITERATIONS 10 +namespace { // anonymous namespace struct pj_opaque { double t_obs; double t_epoch; PJ *cart; }; +} // anonymous namespace /********************************************************************************/ static XYZ get_grid_shift(PJ* P, XYZ cartesian) { diff --git a/src/PJ_eck3.cpp b/src/PJ_eck3.cpp index 7993d781..beaf9357 100644 --- a/src/PJ_eck3.cpp +++ b/src/PJ_eck3.cpp @@ -10,9 +10,11 @@ PROJ_HEAD(putp1, "Putnins P1") "\n\tPCyl, Sph"; PROJ_HEAD(wag6, "Wagner VI") "\n\tPCyl, Sph"; PROJ_HEAD(kav7, "Kavraisky VII") "\n\tPCyl, Sph"; +namespace { // anonymous namespace struct pj_opaque { double C_x, C_y, A, B; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_eqc.cpp b/src/PJ_eqc.cpp index b95471f7..f31da20a 100644 --- a/src/PJ_eqc.cpp +++ b/src/PJ_eqc.cpp @@ -6,9 +6,11 @@ #include "proj.h" #include "projects.h" +namespace { // anonymous namespace struct pj_opaque { double rc; }; +} // anonymous namespace PROJ_HEAD(eqc, "Equidistant Cylindrical (Plate Carree)") "\n\tCyl, Sph\n\tlat_ts=[, lat_0=0]"; diff --git a/src/PJ_eqdc.cpp b/src/PJ_eqdc.cpp index 468b16df..7e5cd0da 100644 --- a/src/PJ_eqdc.cpp +++ b/src/PJ_eqdc.cpp @@ -7,6 +7,7 @@ #include "projects.h" #include "proj_math.h" +namespace { // anonymous namespace struct pj_opaque { double phi1; double phi2; @@ -17,6 +18,7 @@ struct pj_opaque { double *en; int ellips; }; +} // anonymous namespace PROJ_HEAD(eqdc, "Equidistant Conic") "\n\tConic, Sph&Ell\n\tlat_1= lat_2="; diff --git a/src/PJ_eqearth.cpp b/src/PJ_eqearth.cpp index 34d85fa5..3547d683 100644 --- a/src/PJ_eqearth.cpp +++ b/src/PJ_eqearth.cpp @@ -31,11 +31,13 @@ PROJ_HEAD(eqearth, "Equal Earth") "\n\tPCyl, Sph&Ell"; #define EPS 1e-11 #define MAX_ITER 12 +namespace { // anonymous namespace struct pj_opaque { double qp; double rqda; double *apa; }; +} // anonymous namespace static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal/spheroidal, forward */ XY xy = {0.0,0.0}; diff --git a/src/PJ_fouc_s.cpp b/src/PJ_fouc_s.cpp index 8c223336..6f046b0a 100644 --- a/src/PJ_fouc_s.cpp +++ b/src/PJ_fouc_s.cpp @@ -11,9 +11,11 @@ PROJ_HEAD(fouc_s, "Foucaut Sinusoidal") "\n\tPCyl, Sph"; #define MAX_ITER 10 #define LOOP_TOL 1e-7 +namespace { // anonymous namespace struct pj_opaque { double n, n1; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_geos.cpp b/src/PJ_geos.cpp index ffe0771c..6bf7c3f3 100644 --- a/src/PJ_geos.cpp +++ b/src/PJ_geos.cpp @@ -36,6 +36,7 @@ #include "projects.h" #include "proj_math.h" +namespace { // anonymous namespace struct pj_opaque { double h; double radius_p; @@ -46,6 +47,7 @@ struct pj_opaque { double C; int flip_axis; }; +} // anonymous namespace PROJ_HEAD(geos, "Geostationary Satellite View") "\n\tAzi, Sph&Ell\n\th="; diff --git a/src/PJ_gn_sinu.cpp b/src/PJ_gn_sinu.cpp index 2c7824ac..c9885012 100644 --- a/src/PJ_gn_sinu.cpp +++ b/src/PJ_gn_sinu.cpp @@ -15,10 +15,12 @@ PROJ_HEAD(mbtfps, "McBryde-Thomas Flat-Polar Sinusoidal") "\n\tPCyl, Sph"; #define MAX_ITER 8 #define LOOP_TOL 1e-7 +namespace { // anonymous namespace struct pj_opaque { double *en; double m, n, C_x, C_y; }; +} // anonymous namespace static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */ diff --git a/src/PJ_gnom.cpp b/src/PJ_gnom.cpp index 7313643f..27e5f925 100644 --- a/src/PJ_gnom.cpp +++ b/src/PJ_gnom.cpp @@ -11,18 +11,22 @@ PROJ_HEAD(gnom, "Gnomonic") "\n\tAzi, Sph"; #define EPS10 1.e-10 +namespace { // anonymous namespace enum Mode { N_POLE = 0, S_POLE = 1, EQUIT = 2, OBLIQ = 3 }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque { double sinph0; double cosph0; enum Mode mode; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_goode.cpp b/src/PJ_goode.cpp index 3f5a4f8c..14c78439 100644 --- a/src/PJ_goode.cpp +++ b/src/PJ_goode.cpp @@ -13,10 +13,12 @@ PROJ_HEAD(goode, "Goode Homolosine") "\n\tPCyl, Sph"; C_NAMESPACE PJ *pj_sinu(PJ *), *pj_moll(PJ *); +namespace { // anonymous namespace struct pj_opaque { PJ *sinu; PJ *moll; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_gstmerc.cpp b/src/PJ_gstmerc.cpp index 6475f972..01ef796d 100644 --- a/src/PJ_gstmerc.cpp +++ b/src/PJ_gstmerc.cpp @@ -8,6 +8,7 @@ PROJ_HEAD(gstmerc, "Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion)") "\n\tCyl, Sph&Ell\n\tlat_0= lon_0= k_0="; +namespace { // anonymous namespace struct pj_opaque { double lamc; double phic; @@ -17,6 +18,7 @@ struct pj_opaque { double XS; double YS; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_hammer.cpp b/src/PJ_hammer.cpp index 474d44ca..974bc813 100644 --- a/src/PJ_hammer.cpp +++ b/src/PJ_hammer.cpp @@ -11,10 +11,12 @@ PROJ_HEAD(hammer, "Hammer & Eckert-Greifendorff") #define EPS 1.0e-10 +namespace { // anonymous namespace struct pj_opaque { double w; double m, rm; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_healpix.cpp b/src/PJ_healpix.cpp index a7d42398..64b57a26 100644 --- a/src/PJ_healpix.cpp +++ b/src/PJ_healpix.cpp @@ -53,12 +53,14 @@ PROJ_HEAD(rhealpix, "rHEALPix") "\n\tSph&Ell\n\tnorth_square= south_square="; /* Fuzz to handle rounding errors: */ # define EPS 1e-15 +namespace { // anonymous namespace struct pj_opaque { int north_square; int south_square; double qp; double *apa; }; +} // anonymous namespace typedef struct { int cn; /* An integer 0--3 indicating the position of the polar cap. */ diff --git a/src/PJ_helmert.cpp b/src/PJ_helmert.cpp index c19422cb..b2072a84 100644 --- a/src/PJ_helmert.cpp +++ b/src/PJ_helmert.cpp @@ -65,6 +65,7 @@ static LPZ helmert_reverse_3d (XYZ xyz, PJ *P); /***********************************************************************/ +namespace { // anonymous namespace struct pj_opaque_helmert { /************************************************************************ Projection specific elements for the "helmert" PJ object @@ -87,6 +88,7 @@ struct pj_opaque_helmert { int no_rotation, exact, fourparam; int is_position_vector; /* 1 = position_vector, 0 = coordinate_frame */ }; +} // anonymous namespace /* Make the maths of the rotation operations somewhat more readable and textbook like */ diff --git a/src/PJ_hgridshift.cpp b/src/PJ_hgridshift.cpp index 86c6cdee..9ed9ca02 100644 --- a/src/PJ_hgridshift.cpp +++ b/src/PJ_hgridshift.cpp @@ -10,10 +10,12 @@ PROJ_HEAD(hgridshift, "Horizontal grid shift"); +namespace { // anonymous namespace struct pj_opaque_hgridshift { double t_final; double t_epoch; }; +} // anonymous namespace static XYZ forward_3d(LPZ lpz, PJ *P) { PJ_COORD point = {{0,0,0,0}}; diff --git a/src/PJ_horner.cpp b/src/PJ_horner.cpp index 49e108c8..f2d8cb5a 100644 --- a/src/PJ_horner.cpp +++ b/src/PJ_horner.cpp @@ -92,13 +92,7 @@ PROJ_HEAD(horner, "Horner polynomial evaluation"); #define horner_dealloc(x) pj_dealloc(x) #define horner_calloc(n,x) pj_calloc(n,x) - -struct horner; -typedef struct horner HORNER; -static UV horner (const HORNER *transformation, PJ_DIRECTION direction, UV position); -static HORNER *horner_alloc (size_t order, int complex_polynomia); -static void horner_free (HORNER *h); - +namespace { // anonymous namespace struct horner { int uneg; /* u axis negated? */ int vneg; /* v axis negated? */ @@ -118,6 +112,12 @@ struct horner { UV *fwd_origin; /* False longitude/latitude */ UV *inv_origin; /* False easting/northing */ }; +} // anonymous namespace + +typedef struct horner HORNER; +static UV horner_func (const HORNER *transformation, PJ_DIRECTION direction, UV position); +static HORNER *horner_alloc (size_t order, int complex_polynomia); +static void horner_free (HORNER *h); /* e.g. degree = 2: a + bx + cy + dxx + eyy + fxy, i.e. 6 coefficients */ #define horner_number_of_coefficients(order) \ @@ -181,7 +181,7 @@ static HORNER *horner_alloc (size_t order, int complex_polynomia) { /**********************************************************************/ -static UV horner (const HORNER *transformation, PJ_DIRECTION direction, UV position) { +static UV horner_func (const HORNER *transformation, PJ_DIRECTION direction, UV position) { /*********************************************************************** A reimplementation of the classic Engsager/Poder 2D Horner polynomial @@ -297,12 +297,12 @@ summing the tiny high order elements first. static PJ_COORD horner_forward_4d (PJ_COORD point, PJ *P) { - point.uv = horner ((HORNER *) P->opaque, PJ_FWD, point.uv); + point.uv = horner_func ((HORNER *) P->opaque, PJ_FWD, point.uv); return point; } static PJ_COORD horner_reverse_4d (PJ_COORD point, PJ *P) { - point.uv = horner ((HORNER *) P->opaque, PJ_INV, point.uv); + point.uv = horner_func ((HORNER *) P->opaque, PJ_INV, point.uv); return point; } diff --git a/src/PJ_igh.cpp b/src/PJ_igh.cpp index 476d1c6b..60f5a4e8 100644 --- a/src/PJ_igh.cpp +++ b/src/PJ_igh.cpp @@ -32,10 +32,12 @@ static const double d180 = 180 * DEG_TO_RAD; static const double EPSLN = 1.e-10; /* allow a little 'slack' on zone edge positions */ +namespace { // anonymous namespace struct pj_opaque { struct PJconsts* pj[12]; \ double dy0; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_imw_p.cpp b/src/PJ_imw_p.cpp index 7bf9405a..a6e9d0bb 100644 --- a/src/PJ_imw_p.cpp +++ b/src/PJ_imw_p.cpp @@ -12,18 +12,22 @@ PROJ_HEAD(imw_p, "International Map of the World Polyconic") #define TOL 1e-10 #define EPS 1e-10 +namespace { // anonymous namespace enum Mode { NONE_IS_ZERO = 0, /* phi_1 and phi_2 != 0 */ PHI_1_IS_ZERO = 1, /* phi_1 = 0 */ PHI_2_IS_ZERO = -1 /* phi_2 = 0 */ }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque { double P, Pp, Q, Qp, R_1, R_2, sphi_1, sphi_2, C2; double phi_1, phi_2, lam_1; double *en; enum Mode mode; }; +} // anonymous namespace static int phi12(PJ *P, double *del, double *sig) { diff --git a/src/PJ_isea.cpp b/src/PJ_isea.cpp index 6170b8a1..cc0ddf9e 100644 --- a/src/PJ_isea.cpp +++ b/src/PJ_isea.cpp @@ -46,10 +46,12 @@ #define ISEA_STD_LAT 1.01722196792335072101 #define ISEA_STD_LON .19634954084936207740 +namespace { // anonymous namespace struct hex { int iso; long x, y, z; }; +} // anonymous namespace /* y *must* be positive down as the xy /iso conversion assumes this */ static void hex_xy(struct hex *h) { @@ -124,12 +126,15 @@ static void hexbin2(double width, double x, double y, long *i, long *j) { *j = h.y; } +namespace { // anonymous namespace enum isea_poly { ISEA_NONE, ISEA_ICOSAHEDRON = 20 }; enum isea_topology { ISEA_HEXAGON=6, ISEA_TRIANGLE=3, ISEA_DIAMOND=4 }; enum isea_address_form { ISEA_GEO, ISEA_Q2DI, ISEA_SEQNUM, ISEA_INTERLEAVE, ISEA_PLANE, ISEA_Q2DD, ISEA_PROJTRI, ISEA_VERTEX2DD, ISEA_HEX }; +} // anonymous namespace +namespace { // anonymous namespace struct isea_dgg { int polyhedron; /* ignored, icosahedron */ double o_lat, o_lon, o_az; /* orientation, radians */ @@ -143,29 +148,38 @@ struct isea_dgg { int quad; /* quad of last transformed point */ unsigned long serial; }; +} // anonymous namespace +namespace { // anonymous namespace struct isea_pt { double x, y; }; +} // anonymous namespace +namespace { // anonymous namespace struct isea_geo { double lon, lat; }; +} // anonymous namespace /* ENDINC */ +namespace { // anonymous namespace enum snyder_polyhedron { SNYDER_POLY_HEXAGON, SNYDER_POLY_PENTAGON, SNYDER_POLY_TETRAHEDRON, SNYDER_POLY_CUBE, SNYDER_POLY_OCTAHEDRON, SNYDER_POLY_DODECAHEDRON, SNYDER_POLY_ICOSAHEDRON }; +} // anonymous namespace +namespace { // anonymous namespace struct snyder_constants { double g, G, theta; /* cppcheck-suppress unusedStructMember */ double ea_w, ea_a, ea_b, g_w, g_a, g_b; }; +} // anonymous namespace /* TODO put these in radians to avoid a later conversion */ static const struct snyder_constants constants[] = { @@ -974,9 +988,11 @@ static struct isea_pt isea_forward(struct isea_dgg *g, struct isea_geo *in) PROJ_HEAD(isea, "Icosahedral Snyder Equal Area") "\n\tSph"; +namespace { // anonymous namespace struct pj_opaque { struct isea_dgg dgg; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_krovak.cpp b/src/PJ_krovak.cpp index 7e0488f0..7728002a 100644 --- a/src/PJ_krovak.cpp +++ b/src/PJ_krovak.cpp @@ -90,6 +90,7 @@ PROJ_HEAD(krovak, "Krovak") "\n\tPCyl, Ell"; /* Not sure at all of the appropriate number for MAX_ITER... */ #define MAX_ITER 100 +namespace { // anonymous namespace struct pj_opaque { double alpha; double k; @@ -98,6 +99,7 @@ struct pj_opaque { double ad; int czech; }; +} // anonymous namespace static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */ diff --git a/src/PJ_labrd.cpp b/src/PJ_labrd.cpp index e40bbcbd..c72aeb93 100644 --- a/src/PJ_labrd.cpp +++ b/src/PJ_labrd.cpp @@ -8,9 +8,11 @@ PROJ_HEAD(labrd, "Laborde") "\n\tCyl, Sph\n\tSpecial for Madagascar"; #define EPS 1.e-10 +namespace { // anonymous namespace struct pj_opaque { double kRg, p0s, A, C, Ca, Cb, Cc, Cd; }; +} // anonymous namespace static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */ diff --git a/src/PJ_laea.cpp b/src/PJ_laea.cpp index 02b34858..f1626a55 100644 --- a/src/PJ_laea.cpp +++ b/src/PJ_laea.cpp @@ -6,13 +6,16 @@ PROJ_HEAD(laea, "Lambert Azimuthal Equal Area") "\n\tAzi, Sph&Ell"; +namespace { // anonymous namespace enum Mode { N_POLE = 0, S_POLE = 1, EQUIT = 2, OBLIQ = 3 }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque { double sinb1; double cosb1; @@ -25,6 +28,7 @@ struct pj_opaque { double *apa; enum Mode mode; }; +} // anonymous namespace #define EPS10 1.e-10 diff --git a/src/PJ_lagrng.cpp b/src/PJ_lagrng.cpp index f5363287..30306db4 100644 --- a/src/PJ_lagrng.cpp +++ b/src/PJ_lagrng.cpp @@ -9,6 +9,7 @@ PROJ_HEAD(lagrng, "Lagrange") "\n\tMisc Sph\n\tW="; #define TOL 1e-10 +namespace { // anonymous namespace struct pj_opaque { double a1; double a2; @@ -17,6 +18,7 @@ struct pj_opaque { double rw; double w; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_lcc.cpp b/src/PJ_lcc.cpp index 5c430ea0..9483c085 100644 --- a/src/PJ_lcc.cpp +++ b/src/PJ_lcc.cpp @@ -9,6 +9,7 @@ PROJ_HEAD(lcc, "Lambert Conformal Conic") #define EPS10 1.e-10 +namespace { // anonymous namespace struct pj_opaque { double phi1; double phi2; @@ -16,6 +17,7 @@ struct pj_opaque { double rho0; double c; }; +} // anonymous namespace static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */ diff --git a/src/PJ_lcca.cpp b/src/PJ_lcca.cpp index cbb18709..add6dcc7 100644 --- a/src/PJ_lcca.cpp +++ b/src/PJ_lcca.cpp @@ -59,11 +59,13 @@ PROJ_HEAD(lcca, "Lambert Conformal Conic Alternative") #define MAX_ITER 10 #define DEL_TOL 1e-12 +namespace { // anonymous namespace struct pj_opaque { double *en; double r0, l, M0; double C; }; +} // anonymous namespace static double fS(double S, double C) { /* func to compute dr */ diff --git a/src/PJ_loxim.cpp b/src/PJ_loxim.cpp index 28e955d9..fc412997 100644 --- a/src/PJ_loxim.cpp +++ b/src/PJ_loxim.cpp @@ -10,11 +10,13 @@ PROJ_HEAD(loxim, "Loximuthal") "\n\tPCyl Sph"; #define EPS 1e-8 +namespace { // anonymous namespace struct pj_opaque { double phi1; double cosphi1; double tanphi1; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_lsat.cpp b/src/PJ_lsat.cpp index e3e7e026..ba829d42 100644 --- a/src/PJ_lsat.cpp +++ b/src/PJ_lsat.cpp @@ -12,10 +12,12 @@ PROJ_HEAD(lsat, "Space oblique for LANDSAT") #define TOL 1e-7 +namespace { // anonymous namespace struct pj_opaque { double a2, a4, b, c1, c3; double q, t, u, w, p22, sa, ca, xj, rlm, rlm2; }; +} // anonymous namespace static void seraz0(double lam, double mult, PJ *P) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque); diff --git a/src/PJ_misrsom.cpp b/src/PJ_misrsom.cpp index 537172c1..3d8adbe9 100644 --- a/src/PJ_misrsom.cpp +++ b/src/PJ_misrsom.cpp @@ -33,10 +33,12 @@ PROJ_HEAD(misrsom, "Space oblique for MISR") #define TOL 1e-7 +namespace { // anonymous namespace struct pj_opaque { double a2, a4, b, c1, c3; double q, t, u, w, p22, sa, ca, xj, rlm, rlm2; }; +} // anonymous namespace static void seraz0(double lam, double mult, PJ *P) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque); diff --git a/src/PJ_mod_ster.cpp b/src/PJ_mod_ster.cpp index ad5c9cdb..7ef34f0a 100644 --- a/src/PJ_mod_ster.cpp +++ b/src/PJ_mod_ster.cpp @@ -12,11 +12,13 @@ PROJ_HEAD(gs50, "Mod. Stereographic of 50 U.S.") "\n\tAzi(mod)"; #define EPSLN 1e-12 +namespace { // anonymous namespace struct pj_opaque { const COMPLEX *zcoeff; \ double cchio, schio; \ int n; }; +} // anonymous namespace static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */ diff --git a/src/PJ_moll.cpp b/src/PJ_moll.cpp index ed7e946d..aed16132 100644 --- a/src/PJ_moll.cpp +++ b/src/PJ_moll.cpp @@ -12,9 +12,11 @@ PROJ_HEAD(wag5, "Wagner V") "\n\tPCyl, Sph"; #define MAX_ITER 10 #define LOOP_TOL 1e-7 +namespace { // anonymous namespace struct pj_opaque { double C_x, C_y, C_p; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_molodensky.cpp b/src/PJ_molodensky.cpp index 6b231081..6ed8dd33 100644 --- a/src/PJ_molodensky.cpp +++ b/src/PJ_molodensky.cpp @@ -56,6 +56,7 @@ PROJ_HEAD(molodensky, "Molodensky transform"); static XYZ forward_3d(LPZ lpz, PJ *P); static LPZ reverse_3d(XYZ xyz, PJ *P); +namespace { // anonymous namespace struct pj_opaque_molodensky { double dx; double dy; @@ -64,6 +65,7 @@ struct pj_opaque_molodensky { double df; int abridged; }; +} // anonymous namespace static double RN (double a, double es, double phi) { diff --git a/src/PJ_nsper.cpp b/src/PJ_nsper.cpp index e6ecb852..beace3d9 100644 --- a/src/PJ_nsper.cpp +++ b/src/PJ_nsper.cpp @@ -4,13 +4,16 @@ #include "projects.h" #include "proj_math.h" +namespace { // anonymous namespace enum Mode { N_POLE = 0, S_POLE = 1, EQUIT = 2, OBLIQ = 3 }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque { double height; double sinph0; @@ -27,6 +30,7 @@ struct pj_opaque { enum Mode mode; int tilt; }; +} // anonymous namespace PROJ_HEAD(nsper, "Near-sided perspective") "\n\tAzi, Sph\n\th="; PROJ_HEAD(tpers, "Tilted perspective") "\n\tAzi, Sph\n\ttilt= azi= h="; diff --git a/src/PJ_ob_tran.cpp b/src/PJ_ob_tran.cpp index 1a9417b8..ee1dc465 100644 --- a/src/PJ_ob_tran.cpp +++ b/src/PJ_ob_tran.cpp @@ -7,11 +7,13 @@ #include "proj.h" #include "projects.h" +namespace { // anonymous namespace struct pj_opaque { struct PJconsts *link; double lamp; double cphip, sphip; }; +} // anonymous namespace PROJ_HEAD(ob_tran, "General Oblique Transformation") "\n\tMisc Sph" "\n\to_proj= plus parameters for projection" diff --git a/src/PJ_ocea.cpp b/src/PJ_ocea.cpp index 81c506fe..414c296f 100644 --- a/src/PJ_ocea.cpp +++ b/src/PJ_ocea.cpp @@ -8,6 +8,7 @@ PROJ_HEAD(ocea, "Oblique Cylindrical Equal Area") "\n\tCyl, Sph" "lonc= alpha= or\n\tlat_1= lat_2= lon_1= lon_2="; +namespace { // anonymous namespace struct pj_opaque { double rok; double rtk; @@ -16,6 +17,7 @@ struct pj_opaque { double singam; double cosgam; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_oea.cpp b/src/PJ_oea.cpp index b39e8d5a..0b558f83 100644 --- a/src/PJ_oea.cpp +++ b/src/PJ_oea.cpp @@ -6,12 +6,14 @@ PROJ_HEAD(oea, "Oblated Equal Area") "\n\tMisc Sph\n\tn= m= theta="; +namespace { // anonymous namespace struct pj_opaque { double theta; double m, n; double two_r_m, two_r_n, rm, rn, hm, hn; double cp0, sp0; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_omerc.cpp b/src/PJ_omerc.cpp index 27b65cc7..dbf90230 100644 --- a/src/PJ_omerc.cpp +++ b/src/PJ_omerc.cpp @@ -33,11 +33,13 @@ PROJ_HEAD(omerc, "Oblique Mercator") "\n\tCyl, Sph&Ell no_rot\n\t" "alpha= [gamma=] [no_off] lonc= or\n\t lon_1= lat_1= lon_2= lat_2="; +namespace { // anonymous namespace struct pj_opaque { double A, B, E, AB, ArB, BrA, rB, singam, cosgam, sinrot, cosrot; double v_pole_n, v_pole_s, u_0; int no_rot; }; +} // anonymous namespace #define TOL 1.e-7 #define EPS 1.e-10 diff --git a/src/PJ_ortho.cpp b/src/PJ_ortho.cpp index 0e3641c0..4f5cf99a 100644 --- a/src/PJ_ortho.cpp +++ b/src/PJ_ortho.cpp @@ -7,18 +7,22 @@ PROJ_HEAD(ortho, "Orthographic") "\n\tAzi, Sph"; +namespace { // anonymous namespace enum Mode { N_POLE = 0, S_POLE = 1, EQUIT = 2, OBLIQ = 3 }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque { double sinph0; double cosph0; enum Mode mode; }; +} // anonymous namespace #define EPS10 1.e-10 diff --git a/src/PJ_pipeline.cpp b/src/PJ_pipeline.cpp index c20454df..bf28e93e 100644 --- a/src/PJ_pipeline.cpp +++ b/src/PJ_pipeline.cpp @@ -109,12 +109,14 @@ Thomas Knudsen, thokn@sdfe.dk, 2016-05-20 PROJ_HEAD(pipeline, "Transformation pipeline manager"); /* Projection specific elements for the PJ object */ +namespace { // anonymous namespace struct pj_opaque { int steps; char **argv; char **current_argv; PJ **pipeline; }; +} // anonymous namespace diff --git a/src/PJ_poly.cpp b/src/PJ_poly.cpp index 3bf7a8dd..9eb97467 100644 --- a/src/PJ_poly.cpp +++ b/src/PJ_poly.cpp @@ -9,10 +9,12 @@ PROJ_HEAD(poly, "Polyconic (American)") "\n\tConic, Sph&Ell"; +namespace { // anonymous namespace struct pj_opaque { double ml0; \ double *en; }; +} // anonymous namespace #define TOL 1e-10 #define CONV 1e-10 diff --git a/src/PJ_putp3.cpp b/src/PJ_putp3.cpp index 6e85d35f..c55a1732 100644 --- a/src/PJ_putp3.cpp +++ b/src/PJ_putp3.cpp @@ -2,9 +2,11 @@ #include <errno.h> #include "projects.h" +namespace { // anonymous namespace struct pj_opaque { double A; }; +} // anonymous namespace PROJ_HEAD(putp3, "Putnins P3") "\n\tPCyl, Sph"; PROJ_HEAD(putp3p, "Putnins P3'") "\n\tPCyl, Sph"; diff --git a/src/PJ_putp4p.cpp b/src/PJ_putp4p.cpp index 77a18651..2ad20d1b 100644 --- a/src/PJ_putp4p.cpp +++ b/src/PJ_putp4p.cpp @@ -5,9 +5,11 @@ #include "projects.h" +namespace { // anonymous namespace struct pj_opaque { double C_x, C_y; }; +} // anonymous namespace PROJ_HEAD(putp4p, "Putnins P4'") "\n\tPCyl, Sph"; PROJ_HEAD(weren, "Werenskiold I") "\n\tPCyl, Sph"; diff --git a/src/PJ_putp5.cpp b/src/PJ_putp5.cpp index d73e9368..41849f33 100644 --- a/src/PJ_putp5.cpp +++ b/src/PJ_putp5.cpp @@ -5,9 +5,11 @@ #include "projects.h" +namespace { // anonymous namespace struct pj_opaque { double A, B; }; +} // anonymous namespace PROJ_HEAD(putp5, "Putnins P5") "\n\tPCyl, Sph"; PROJ_HEAD(putp5p, "Putnins P5'") "\n\tPCyl, Sph"; diff --git a/src/PJ_putp6.cpp b/src/PJ_putp6.cpp index fcd8146f..bfa7d908 100644 --- a/src/PJ_putp6.cpp +++ b/src/PJ_putp6.cpp @@ -5,9 +5,11 @@ #include "projects.h" +namespace { // anonymous namespace struct pj_opaque { double C_x, C_y, A, B, D; }; +} // anonymous namespace PROJ_HEAD(putp6, "Putnins P6") "\n\tPCyl, Sph"; PROJ_HEAD(putp6p, "Putnins P6'") "\n\tPCyl, Sph"; diff --git a/src/PJ_qsc.cpp b/src/PJ_qsc.cpp index 767ed4a8..bca7c4fb 100644 --- a/src/PJ_qsc.cpp +++ b/src/PJ_qsc.cpp @@ -46,6 +46,7 @@ #include "projects.h" /* The six cube faces. */ +namespace { // anonymous namespace enum Face { FACE_FRONT = 0, FACE_RIGHT = 1, @@ -54,7 +55,9 @@ enum Face { FACE_TOP = 4, FACE_BOTTOM = 5 }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque { enum Face face; double a_squared; @@ -62,18 +65,21 @@ struct pj_opaque { double one_minus_f; double one_minus_f_squared; }; +} // anonymous namespace PROJ_HEAD(qsc, "Quadrilateralized Spherical Cube") "\n\tAzi, Sph"; #define EPS10 1.e-10 /* The four areas on a cube face. AREA_0 is the area of definition, * the other three areas are counted counterclockwise. */ +namespace { // anonymous namespace enum Area { AREA_0 = 0, AREA_1 = 1, AREA_2 = 2, AREA_3 = 3 }; +} // anonymous namespace /* Helper function for forward projection: compute the theta angle * and determine the area number. */ diff --git a/src/PJ_robin.cpp b/src/PJ_robin.cpp index 19bdc2dc..987977ae 100644 --- a/src/PJ_robin.cpp +++ b/src/PJ_robin.cpp @@ -18,9 +18,11 @@ http://article.gmane.org/gmane.comp.gis.proj-4.devel/6039 http://trac.osgeo.org/proj/ticket/113 */ +namespace { // anonymous namespace struct COEFS { float c0, c1, c2, c3; }; +} // anonymous namespace static const struct COEFS X[] = { {1.0f, 2.2199e-17f, -7.15515e-05f, 3.1103e-06f}, diff --git a/src/PJ_rpoly.cpp b/src/PJ_rpoly.cpp index 24360965..a3b07c45 100644 --- a/src/PJ_rpoly.cpp +++ b/src/PJ_rpoly.cpp @@ -5,12 +5,14 @@ #include "projects.h" +namespace { // anonymous namespace struct pj_opaque { double phi1; double fxa; double fxb; int mode; }; +} // anonymous namespace PROJ_HEAD(rpoly, "Rectangular Polyconic") "\n\tConic, Sph, no inv\n\tlat_ts="; diff --git a/src/PJ_sch.cpp b/src/PJ_sch.cpp index 4a0b1fb8..23b6c4c2 100644 --- a/src/PJ_sch.cpp +++ b/src/PJ_sch.cpp @@ -39,6 +39,7 @@ #include "projects.h" #include "geocent.h" +namespace { // anonymous namespace struct pj_opaque { double plat; /*Peg Latitude */ double plon; /*Peg Longitude*/ @@ -50,6 +51,7 @@ struct pj_opaque { GeocentricInfo sph; GeocentricInfo elp_0; }; +} // anonymous namespace PROJ_HEAD(sch, "Spherical Cross-track Height") "\n\tMisc\n\tplat_0= plon_0= phdg_0= [h_0=]"; diff --git a/src/PJ_sconics.cpp b/src/PJ_sconics.cpp index 4efec86f..788bdb02 100644 --- a/src/PJ_sconics.cpp +++ b/src/PJ_sconics.cpp @@ -5,6 +5,7 @@ #include "proj_math.h" +namespace { // anonymous namespace enum Type { EULER = 0, MURD1 = 1, @@ -14,7 +15,9 @@ enum Type { TISSOT = 5, VITK1 = 6 }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque { double n; double rho_c; @@ -23,6 +26,7 @@ struct pj_opaque { double c1, c2; enum Type type; }; +} // anonymous namespace #define EPS10 1.e-10 diff --git a/src/PJ_somerc.cpp b/src/PJ_somerc.cpp index 6a98f76f..b82f1a58 100644 --- a/src/PJ_somerc.cpp +++ b/src/PJ_somerc.cpp @@ -8,9 +8,11 @@ PROJ_HEAD(somerc, "Swiss. Obl. Mercator") "\n\tCyl, Ell\n\tFor CH1903"; +namespace { // anonymous namespace struct pj_opaque { double K, c, hlf_e, kR, cosp0, sinp0; }; +} // anonymous namespace #define EPS 1.e-10 #define NITER 6 diff --git a/src/PJ_stere.cpp b/src/PJ_stere.cpp index 94e7f91d..58d5858d 100644 --- a/src/PJ_stere.cpp +++ b/src/PJ_stere.cpp @@ -8,13 +8,16 @@ PROJ_HEAD(stere, "Stereographic") "\n\tAzi, Sph&Ell\n\tlat_ts="; PROJ_HEAD(ups, "Universal Polar Stereographic") "\n\tAzi, Sph&Ell\n\tsouth"; +namespace { // anonymous namespace enum Mode { S_POLE = 0, N_POLE = 1, OBLIQ = 2, EQUIT = 3 }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque { double phits; double sinX1; @@ -22,6 +25,7 @@ struct pj_opaque { double akm1; enum Mode mode; }; +} // anonymous namespace #define sinph0 static_cast<struct pj_opaque*>(P->opaque)->sinX1 #define cosph0 static_cast<struct pj_opaque*>(P->opaque)->cosX1 diff --git a/src/PJ_sterea.cpp b/src/PJ_sterea.cpp index 4c2fe2a3..05a6e5e3 100644 --- a/src/PJ_sterea.cpp +++ b/src/PJ_sterea.cpp @@ -29,12 +29,14 @@ #include "proj_math.h" +namespace { // anonymous namespace struct pj_opaque { double phic0; double cosc0, sinc0; double R2; void *en; }; +} // anonymous namespace PROJ_HEAD(sterea, "Oblique Stereographic Alternative") "\n\tAzimuthal, Sph&Ell"; diff --git a/src/PJ_sts.cpp b/src/PJ_sts.cpp index 4aece68e..bc56ed81 100644 --- a/src/PJ_sts.cpp +++ b/src/PJ_sts.cpp @@ -11,10 +11,12 @@ PROJ_HEAD(fouc, "Foucaut") "\n\tPCyl, Sph"; PROJ_HEAD(mbt_s, "McBryde-Thomas Flat-Polar Sine (No. 1)") "\n\tPCyl, Sph"; +namespace { // anonymous namespace struct pj_opaque { double C_x, C_y, C_p; int tan_mode; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_tmerc.cpp b/src/PJ_tmerc.cpp index 55f878c9..ac6319ff 100644 --- a/src/PJ_tmerc.cpp +++ b/src/PJ_tmerc.cpp @@ -9,11 +9,13 @@ PROJ_HEAD(tmerc, "Transverse Mercator") "\n\tCyl, Sph&Ell"; +namespace { // anonymous namespace struct pj_opaque { double esp; double ml0; double *en; }; +} // anonymous namespace #define EPS10 1.e-10 #define FC1 1. diff --git a/src/PJ_tpeqd.cpp b/src/PJ_tpeqd.cpp index 5691cd7b..a1c049aa 100644 --- a/src/PJ_tpeqd.cpp +++ b/src/PJ_tpeqd.cpp @@ -8,10 +8,12 @@ PROJ_HEAD(tpeqd, "Two Point Equidistant") "\n\tMisc Sph\n\tlat_1= lon_1= lat_2= lon_2="; +namespace { // anonymous namespace struct pj_opaque { double cp1, sp1, cp2, sp2, ccs, cs, sc, r2z0, z02, dlam2; double hz0, thz0, rhshz0, ca, sa, lp, lamc; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_unitconvert.cpp b/src/PJ_unitconvert.cpp index 7476620e..09eb3ae8 100644 --- a/src/PJ_unitconvert.cpp +++ b/src/PJ_unitconvert.cpp @@ -78,19 +78,23 @@ PROJ_HEAD(unitconvert, "Unit conversion"); typedef double (*tconvert)(double); +namespace { // anonymous namespace struct TIME_UNITS { char *id; /* units keyword */ tconvert t_in; /* unit -> mod. julian date function pointer */ tconvert t_out; /* mod. julian date > unit function pointer */ char *name; /* comments */ }; +} // anonymous namespace +namespace { // anonymous namespace struct pj_opaque_unitconvert { int t_in_id; /* time unit id for the time input unit */ int t_out_id; /* time unit id for the time output unit */ double xy_factor; /* unit conversion factor for horizontal components */ double z_factor; /* unit conversion factor for vertical components */ }; +} // anonymous namespace /***********************************************************************/ diff --git a/src/PJ_urm5.cpp b/src/PJ_urm5.cpp index 6a208647..f16d1534 100644 --- a/src/PJ_urm5.cpp +++ b/src/PJ_urm5.cpp @@ -8,9 +8,11 @@ PROJ_HEAD(urm5, "Urmaev V") "\n\tPCyl, Sph, no inv\n\tn= q= alpha="; +namespace { // anonymous namespace struct pj_opaque { double m, rmn, q3, n; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_urmfps.cpp b/src/PJ_urmfps.cpp index 1d147b9c..848ba4f9 100644 --- a/src/PJ_urmfps.cpp +++ b/src/PJ_urmfps.cpp @@ -9,9 +9,11 @@ PROJ_HEAD(urmfps, "Urmaev Flat-Polar Sinusoidal") "\n\tPCyl, Sph\n\tn="; PROJ_HEAD(wag1, "Wagner I (Kavraisky VI)") "\n\tPCyl, Sph"; +namespace { // anonymous namespace struct pj_opaque { double n, C_y; }; +} // anonymous namespace #define C_x 0.8773826753 #define Cy 1.139753528477 diff --git a/src/PJ_vandg2.cpp b/src/PJ_vandg2.cpp index 588366cf..f414f1ef 100644 --- a/src/PJ_vandg2.cpp +++ b/src/PJ_vandg2.cpp @@ -5,9 +5,11 @@ #include "projects.h" +namespace { // anonymous namespace struct pj_opaque { int vdg3; }; +} // anonymous namespace PROJ_HEAD(vandg2, "van der Grinten II") "\n\tMisc Sph, no inv"; PROJ_HEAD(vandg3, "van der Grinten III") "\n\tMisc Sph, no inv"; diff --git a/src/PJ_vgridshift.cpp b/src/PJ_vgridshift.cpp index 8aad3777..bf1300c7 100644 --- a/src/PJ_vgridshift.cpp +++ b/src/PJ_vgridshift.cpp @@ -10,11 +10,13 @@ PROJ_HEAD(vgridshift, "Vertical grid shift"); +namespace { // anonymous namespace struct pj_opaque_vgridshift { double t_final; double t_epoch; double forward_multiplier; }; +} // anonymous namespace static XYZ forward_3d(LPZ lpz, PJ *P) { struct pj_opaque_vgridshift *Q = (struct pj_opaque_vgridshift *) P->opaque; diff --git a/src/PJ_wag3.cpp b/src/PJ_wag3.cpp index 0eeb73df..f0443688 100644 --- a/src/PJ_wag3.cpp +++ b/src/PJ_wag3.cpp @@ -9,9 +9,11 @@ PROJ_HEAD(wag3, "Wagner III") "\n\tPCyl, Sph\n\tlat_ts="; #define TWOTHIRD 0.6666666666666666666667 +namespace { // anonymous namespace struct pj_opaque { double C_x; }; +} // anonymous namespace static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ diff --git a/src/PJ_wink1.cpp b/src/PJ_wink1.cpp index 6640f995..e466988f 100644 --- a/src/PJ_wink1.cpp +++ b/src/PJ_wink1.cpp @@ -7,9 +7,11 @@ PROJ_HEAD(wink1, "Winkel I") "\n\tPCyl, Sph\n\tlat_ts="; +namespace { // anonymous namespace struct pj_opaque { double cosphi1; }; +} // anonymous namespace diff --git a/src/PJ_wink2.cpp b/src/PJ_wink2.cpp index 9da65eaa..3935372a 100644 --- a/src/PJ_wink2.cpp +++ b/src/PJ_wink2.cpp @@ -7,7 +7,11 @@ PROJ_HEAD(wink2, "Winkel II") "\n\tPCyl, Sph, no inv\n\tlat_1="; -struct pj_opaque { double cosphi1; }; +namespace { // anonymous namespace +struct pj_opaque { + double cosphi1; +}; +} // anonymous namespace #define MAX_ITER 10 #define LOOP_TOL 1e-7 diff --git a/src/gie.cpp b/src/gie.cpp index 74d78db5..77c21083 100644 --- a/src/gie.cpp +++ b/src/gie.cpp @@ -1020,6 +1020,7 @@ static int dispatch (const char *cmnd, const char *args) { +namespace { // anonymous namespace struct errno_vs_err_const {const char *the_err_const; int the_errno;}; static const struct errno_vs_err_const lookup[] = { {"pjd_err_no_args" , -1}, @@ -1084,6 +1085,7 @@ static const struct errno_vs_err_const lookup[] = { {"pjd_err_unknown" , 9999}, {"pjd_err_enomem" , ENOMEM}, }; +} // anonymous namespace static const struct errno_vs_err_const unknown = {"PJD_ERR_UNKNOWN", 9999}; diff --git a/src/pj_gauss.cpp b/src/pj_gauss.cpp index 4520bb39..45b93f59 100644 --- a/src/pj_gauss.cpp +++ b/src/pj_gauss.cpp @@ -32,12 +32,14 @@ #define MAX_ITER 20 +namespace { // anonymous namespace struct GAUSS { double C; double K; double e; double ratexp; }; +} // anonymous namespace #define DEL_TOL 1e-14 static double srat(double esinp, double ratexp) { diff --git a/src/proj_etmerc.cpp b/src/proj_etmerc.cpp index 0ba710d7..b521c329 100644 --- a/src/proj_etmerc.cpp +++ b/src/proj_etmerc.cpp @@ -47,6 +47,7 @@ #include "proj_math.h" +namespace { // anonymous namespace struct pj_opaque { double Qn; /* Merid. quad., scaled to the projection */ \ double Zb; /* Radius vector in polar coord. systems */ \ @@ -55,6 +56,7 @@ struct pj_opaque { double utg[6]; /* Constants for transv. merc. -> geo */ \ double gtu[6]; /* Constants for geo -> transv. merc. */ }; +} // anonymous namespace PROJ_HEAD(etmerc, "Extended Transverse Mercator") "\n\tCyl, Sph\n\tlat_ts=(0)\nlat_0=(0)"; diff --git a/src/proj_mdist.cpp b/src/proj_mdist.cpp index 777f704d..c645d117 100644 --- a/src/proj_mdist.cpp +++ b/src/proj_mdist.cpp @@ -37,12 +37,14 @@ #define MAX_ITER 20 #define TOL 1e-14 +namespace { // anonymous namespace struct MDIST { int nb; double es; double E; double b[1]; }; +} // anonymous namespace void * proj_mdist_ini(double es) { double numf, numfi, twon1, denf, denfi, ens, T, twon; diff --git a/src/proj_rouss.cpp b/src/proj_rouss.cpp index f39e0a15..f4fa084f 100644 --- a/src/proj_rouss.cpp +++ b/src/proj_rouss.cpp @@ -31,6 +31,7 @@ #include "proj.h" #include "projects.h" +namespace { // anonymous namespace struct pj_opaque { double s0; double A1, A2, A3, A4, A5, A6; @@ -39,6 +40,7 @@ struct pj_opaque { double D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11; void *en; }; +} // anonymous namespace PROJ_HEAD(rouss, "Roussilhe Stereographic") "\n\tAzi, Ell"; diff --git a/src/projinfo.cpp b/src/projinfo.cpp index 89b42e12..d604365a 100644 --- a/src/projinfo.cpp +++ b/src/projinfo.cpp @@ -56,6 +56,7 @@ using namespace NS_PROJ::internal; // --------------------------------------------------------------------------- +namespace { // anonymous namespace struct OutputOptions { bool quiet = false; bool PROJ5 = false; @@ -69,6 +70,7 @@ struct OutputOptions { bool c_ify = false; bool singleLine = false; }; +} // anonymous namespace // --------------------------------------------------------------------------- |
