From 93d8f3a3504c1e92333524aa6aeca169c103166a Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 18 Dec 2018 20:58:28 +0100 Subject: 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 --- src/PJ_unitconvert.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/PJ_unitconvert.cpp') 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 /***********************************************************************/ -- cgit v1.2.3