From 61316648b801e4726876e07ef4cf1dda46d488be Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 9 Nov 2017 13:00:27 -0800 Subject: [PATCH] Bug 789608 - Compilation problems when linking libraries. Fix using a preproc macro in a different file from where it was declared and more-strict template resolution of error_handler<> by gcc-7.x. --- libgnucash/backend/dbi/gnc-backend-dbi.cpp | 5 ++--- libgnucash/backend/dbi/gnc-dbisqlresult.cpp | 17 +++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/libgnucash/backend/dbi/gnc-backend-dbi.cpp b/libgnucash/backend/dbi/gnc-backend-dbi.cpp index 9ea372321f..4e6077e6ae 100644 --- a/libgnucash/backend/dbi/gnc-backend-dbi.cpp +++ b/libgnucash/backend/dbi/gnc-backend-dbi.cpp @@ -93,7 +93,6 @@ extern "C" #if LIBDBI_VERSION >= 900 #define HAVE_LIBDBI_R 1 -#define HAVE_LIBDBI_TO_LONGLONG 1 static dbi_inst dbi_instance = nullptr; #else #define HAVE_LIBDBI_R 0 @@ -253,8 +252,8 @@ GncDbiBackend::set_standard_connection_options (dbi_conn conn, return true; } -template void error_handler(void* conn, void* data); -void error_handler(void* conn, void* data); +template void error_handler(dbi_conn conn, void* data); +void error_handler(dbi_conn conn, void* data); template dbi_conn GncDbiBackend::conn_setup (PairVec& options, UriStrings& uri) diff --git a/libgnucash/backend/dbi/gnc-dbisqlresult.cpp b/libgnucash/backend/dbi/gnc-dbisqlresult.cpp index 6ceb5953af..4115a1124c 100644 --- a/libgnucash/backend/dbi/gnc-dbisqlresult.cpp +++ b/libgnucash/backend/dbi/gnc-dbisqlresult.cpp @@ -36,6 +36,12 @@ extern "C" static QofLogModule log_module = G_LOG_DOMAIN; +#if LIBDBI_VERSION >= 900 +#define HAVE_LIBDBI_TO_LONGLONG 1 +#else +#define HAVE_LIBDBI_TO_LONGLONG 0 +#endif + GncDbiSqlResult::~GncDbiSqlResult() { int status = dbi_result_free (m_dbi_result); @@ -152,17 +158,17 @@ GncDbiSqlResult::IteratorImpl::get_string_at_col(const char* col) const time64 GncDbiSqlResult::IteratorImpl::get_time64_at_col (const char* col) const { - auto type = dbi_result_get_field_type (m_inst->m_dbi_result, col); - auto attrs = dbi_result_get_field_attribs (m_inst->m_dbi_result, col); + auto result = (dbi_result_t*) (m_inst->m_dbi_result); + auto type = dbi_result_get_field_type (result, col); + auto attrs = dbi_result_get_field_attribs (result, col); if (type != DBI_TYPE_DATETIME) throw (std::invalid_argument{"Requested time64 from non-time64 column."}); gnc_push_locale (LC_NUMERIC, "C"); #if HAVE_LIBDBI_TO_LONGLONG - /* A less evil hack than the one equrie by libdbi-0.8, but + /* A less evil hack than the one required by libdbi-0.8, but * still necessary to work around the same bug. */ - auto retval = dbi_result_get_as_longlong(dbi_row->result, - col_name); + auto retval = dbi_result_get_as_longlong(result, col); #else /* A seriously evil hack to work around libdbi bug #15 * https://sourceforge.net/p/libdbi/bugs/15/. When libdbi @@ -170,7 +176,6 @@ GncDbiSqlResult::IteratorImpl::get_time64_at_col (const char* col) const * dbi_result_get_as_longlong. * Note: 0.9 is available in Debian Jessie and Fedora 21. */ - auto result = (dbi_result_t*) (m_inst->m_dbi_result); auto row = dbi_result_get_currow (result); auto idx = dbi_result_get_field_idx (result, col) - 1; time64 retval = result->rows[row]->field_values[idx].d_datetime;