Discussion:
[soci-users] Compile error in core\exchange-traits.h with PG and boost::tuple
Lawry, Brian
2015-12-06 23:06:19 UTC
Permalink
Hi.

Configuration:
Using SOCI 3.2.3, Boost 1.59.0, PostgreSQL 9.4 (same with 9.5b2),
and Microsoft Visual Studio 2010 on Win 7 Pro 64-bit (everything but OS is 32-bit).

Target is 32-bit SOCI DLL with PostgreSQL support and Boost integration (at least tuple).

Ran 'soci_postgresql_test.exe' and all tests under 'SOCI PostgreSQL Tests' passed except:
test 6 skipped (dynamic backend)
NOTICE: table "soci_test" does not exist, skipping
NOTICE: table "soci_json_test" does not exist, skipping
NOTICE: table "soci_test" does not exist, skipping

Can build application that doesn't use boost::tuple without error.
However, if I do use boost:tuple, I get:
c:\develop\soci-3.2.3\core\exchange-traits.h(40): error C2065: 'x_type' : undeclared identifier


// ----example-----------------------------------------------------
//#define _USE_BOOST_TUPLE_

#include "stdafx.h"
/* stdafx.h includes:
#define _ITERATOR_DEBUG_LEVEL 0
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
*/

#include <string>
#include <iostream>
#include <boost/tuple/tuple.hpp>

#include <boost-tuple.h>
#include <soci.h>
#include <soci-postgresql.h>
#pragma comment(lib, "libsoci_core_3_2.lib")
#pragma comment(lib, "libsoci_postgresql_3_2.lib")
#pragma comment(lib, "libpq.lib")

int _tmain(int argc, _TCHAR* argv[])
{
soci::session sql(soci::postgresql, "host=localhost user=postgres password=XXXXX dbname=postgres port=5432");

sql << "CREATE TABLE IF NOT EXISTS t (i INTEGER, s TEXT)";
sql << "TRUNCATE TABLE t";
sql << "INSERT INTO t (i, s) VALUES (0, 'frist')";

int i;
std::string s;
sql << "SELECT i, s FROM t WHERE i = 0", soci::into(i), soci::into(s);
std::cout << i << "\t" << s << std::endl;

boost::tuple<int, std::string> r;
// following line causes error C2065: 'x_type' : undeclared identifier in core\exchange-traits.h
sql << "SELECT i, s FROM t WHERE i = 0", soci::into(r);
std::cout << r.get<0>() << "\t" << r.get<1>() << std::endl;

return(0);
}
//---------------------------------------------------------------------

Thanks.

Brian Lawry
Manufacturing Software Engineer
Compressor Controls Corp
Mateusz Loskot
2015-12-07 05:14:43 UTC
Permalink
Looks similar to https://github.com/SOCI/soci/issues/429

See possible workaround in comments.
There is fix on the way to master too
https://github.com/SOCI/soci/issues/433

Mateusz Łoskot
(Sent from mobile)
Post by Lawry, Brian
Hi.
Using SOCI 3.2.3, Boost 1.59.0, PostgreSQL 9.4 (same with 9.5b2),
and Microsoft Visual Studio 2010 on Win 7 Pro 64-bit (everything but OS is 32-bit).
Target is 32-bit SOCI DLL with PostgreSQL support and Boost integration (at least tuple).
test 6 skipped (dynamic backend)
NOTICE: table "soci_test" does not exist, skipping
NOTICE: table "soci_json_test" does not exist, skipping
NOTICE: table "soci_test" does not exist, skipping
Can build application that doesn't use boost::tuple without error.
c:\develop\soci-3.2.3\core\exchange-traits.h(40): error C2065: 'x_type'
: undeclared identifier
// ----example-----------------------------------------------------
//#define _USE_BOOST_TUPLE_
#include "stdafx.h"
#define _ITERATOR_DEBUG_LEVEL 0
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
*/
#include <string>
#include <iostream>
#include <boost/tuple/tuple.hpp>
#include <boost-tuple.h>
#include <soci.h>
#include <soci-postgresql.h>
#pragma comment(lib, "libsoci_core_3_2.lib")
#pragma comment(lib, "libsoci_postgresql_3_2.lib")
#pragma comment(lib, "libpq.lib")
int _tmain(int argc, _TCHAR* argv[])
{
soci::session sql(soci::postgresql, "host=localhost user=postgres
password=XXXXX dbname=postgres port=5432");
sql << "CREATE TABLE IF NOT EXISTS t (i INTEGER, s TEXT)";
sql << "TRUNCATE TABLE t";
sql << "INSERT INTO t (i, s) VALUES (0, 'frist')";
int i;
std::string s;
sql << "SELECT i, s FROM t WHERE i = 0", soci::into(i), soci::into(s);
std::cout << i << "\t" << s << std::endl;
boost::tuple<int, std::string> r;
// following line causes error C2065: 'x_type' : undeclared identifier in
core\exchange-traits.h
sql << "SELECT i, s FROM t WHERE i = 0", soci::into(r);
std::cout << r.get<0>() << "\t" << r.get<1>() << std::endl;
return(0);
}
//---------------------------------------------------------------------
Thanks.
Brian Lawry
Manufacturing Software Engineer
Compressor Controls Corp
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple
OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
soci-users mailing list
https://lists.sourceforge.net/lists/listinfo/soci-users
Loading...