List:MySQL++« Previous MessageNext Message »
From:MERE2639 Date:April 26 2005 11:50am
Subject:Linking issues using create macro in header
View as plain text  
As previously posted by Chris Gagnon, I have found the reason his compilier 
complains about "_table" and "name" being multiply defined.  Im running into 
the same trouble.  The compiler I am using is VC++ 7.1 

When using the create macro, according to the preprocessor, it expands to 
something like this...

////////////////////////////
...
struct stock
{
....
static const char *names[]; 
static const char *_table;
.....
};

const char *stock::names[] = { "item" , "num" , "weight" , "price" , "date"};
const char *stock::_table = "stock" ;
...
//////////////////////////////

When this is put in a header file, then every where you include that header 
its gonna try to redefine "names" and "_table".

At least this is my understanding of what is wrong.  So i guess the question 
is, can "sql_create_#" be used in a header file and be included every where 
you need it?

I had to modify the custom.pl script to not init these members.  Instead I am 
initializing them in my code manually in a global area.  Does this seem like 
a logical solution?  Just curious.

Mark Merendino

Thread
Linking issues using create macro in headerMERE263926 Apr
  • Re: Linking issues using create macro in headerWarren Young27 Apr
    • Re: Linking issues using create macro in headerWarren Young27 Apr