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 /src/PJ_horner.cpp | |
| 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
Diffstat (limited to 'src/PJ_horner.cpp')
| -rw-r--r-- | src/PJ_horner.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
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; } |
