dbTalk Databases Forums  

Linking issues using create macro in header

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Linking issues using create macro in header in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
MERE2639@aol.com
 
Posts: n/a

Default Linking issues using create macro in header - 04-26-2005 , 06:50 AM






-------------------------------1114516226
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

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

-------------------------------1114516226--

Reply With Quote
  #2  
Old   
Warren Young
 
Posts: n/a

Default Re: Linking issues using create macro in header - 04-26-2005 , 06:17 PM






MERE2639 (AT) aol (DOT) com wrote:
Quote:
As previously posted by Chris Gagnon, I have found the reason his compilier
complains about "_table" and "name" being multiply defined.
I've added an ifdef guard around those definitions so that you can
suppress them if you need to. You will define MYSQLPP_NO_DEFINE_STATICS
before including the header that defines the SSQLS in all but one
location. This will appear in the next version, which should be
appearing soon.

Thanks taking an interest in helping us fix these VC++ problems. None
of the major maintainers use VC++ for MySQL++ development (I use it, but
for other things) so it's good to have someone involved who has a
personal interest in VC++ compatibility. A lot of people just complain
about portability problems and then go away if someone else doesn't
provide a fix for them. Again, thanks.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Warren Young
 
Posts: n/a

Default Re: Linking issues using create macro in header - 04-27-2005 , 02:57 AM



Warren Young wrote:

Quote:
I've added an ifdef guard around those definitions
Alas, this isn't going to work. These definitions are within a macro,
which is effectively on a single C++ line; you can't go putting an ifdef
in the middle of a line.

The only ways I can think of to get around this will break the API, and
possibly also the ABI. So, I'm going to have to defer this fix to a
major release. In the meantime, simply #include the header containing
the SSQLS definition in only one place. I realize this restricts how
you can use MySQL++...but realize that all of us who are using SSQLS now
must be doing this already, and it doesn't seem to bother us any!



--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.