Hi,
What are people's thoughts on using SSQLS structures in header files?
I'd like to define a class with fetches and processes data from a DB.
That class has methods which take and return vectors of rows of the DB,
represented by SSQLS structures.
The header file for this class I need in other source files so I can use it
there. Fine.
Trouble is, when is define a struct using
sql_create_# in the header file, I get a link error complaining about
multiple defintions of symbols <struct name>::names
and <struct name>::_table.
I can't have the sql_create_# statement in the cpp file of the class (and
have a 'struct <struct name>' forward declaration in the header)
because then I can't dereference pointers or use iterators to that struct in
other cpp files, which is what I want to do.
So, what's the solution? Has anyone come across this problem?
I'm running os X 10.4, gcc 4, using Eclipse 3.2 and mysql++2.2.1
as an example one of the structs I want (which I define in the namespace
dbaccesstypes) is
sql_create_7(trade_row, 1, 7,
mysqlpp::DateTime, date,
float, open,
float, high,
float, low,
float, close,
unsigned long, volume,
float, adj_close)
I then want to do in another source file for example
...
vector <dbaccesstypes::trade_row> hist;
DateTime from, to;
from.convert("2006-11-16 00:00:00");
to.convert("2006-12-01 00:00:00");
dba.gethist(hist, from, to, "IBM");
vector<dbaccesstypes::trade_row>::iterator it;
for (it = hist.begin(); it != hist.end(); ++it) {
printf("date: %s, open: %d\n", it->date, it->open);
}
for that I need the full definition of the struct which means putting it in
a header file, which leads to the linker errors...
"/usr/bin/ld: multiple definitions of symbol dbaccesstypes::instinfo::names
./src/Dbaccess.o definition of dbaccesstypes::instinfo::names in
section (__DATA,__data)
./src/dbaccess_test.o definition of dbaccesstypes::instinfo::names in
section (__DATA,__data)
/usr/bin/ld: multiple definitions of symbol dbaccesstypes::instinfo::_table
./src/Dbaccess.o definition of dbaccesstypes::instinfo::_table in
section (__DATA,__data)
./src/dbaccess_test.o definition of dbaccesstypes::instinfo::_table in
section (__DATA,__data)
/usr/bin/ld: multiple definitions of symbol dbaccesstypes::trade_row::names
./src/Dbaccess.o definition of dbaccesstypes::trade_row::names in
section (__DATA,__data)
./src/dbaccess_test.o definition of dbaccesstypes::trade_row::names in
section (__DATA,__data)
/usr/bin/ld: multiple definitions of symbol dbaccesstypes::trade_row::_table
./src/Dbaccess.o definition of dbaccesstypes::trade_row::_table in
section (__DATA,__data)
./src/dbaccess_test.o definition of dbaccesstypes::trade_row::_table in
section (__DATA,__data)"
suggestions please!
thanks,
joe
--
LIVE MUSIC + OTHER PERFORMANCE ART CHARITY FUNDRAISER
Doors 6.30pm - 1st act 7:30pm, 2nd SUNDAY of EVERY month
@ THE TALKING HEADS, PORTSWOOD Rd, SOUTHAMPTON
£4 entrance: all profits to 3 Local Charities. inc:
SCRATCH and HAMPSHIRE AUTISTIC SOCIETY
-----------------------------------------------------------------------------------------------
Apr 8th, May 13th...
Contact joe.hudson@stripped for more info.
-------------------------------------------------------
---------------------------------------
Visit http://www.myspace.com/littlecog for latest details, to post new
events or volunteer for future community action events.