List:MySQL++« Previous MessageNext Message »
From:Simon Pickles Date:December 17 2007 10:12pm
Subject:Re: Linking errors after moving to SSQLSs, macro problem
View as plain text  
Warren Young wrote:
>
> MYSQLPP_SSQLS_NO_STATICS doesn't go in the .h file either
>
Thanks for the informative response, Warren. This all works fine if I 
only put an

#include "ssqls.h"

 ... in .cpp files.

Unfortunately, I need to store types defined by the macros as class 
members. As soon as I add the above include file to the class header 
file so as not to get a type error, it all breaks down with the same 
multiple definitions:


-------------- Build: Debug in mysqlppTest ---------------

Compiling: ClassWithSSQLS.cpp
Compiling: main.cpp
Linking console executable: bin/Debug/mysqlppTest
obj/Debug/main.o:(.data+0x0): multiple definition of `macro::names'
obj/Debug/ClassWithSSQLS.o:(.data+0x0): first defined here
obj/Debug/main.o:(.data+0x8): multiple definition of `macro::_table'
obj/Debug/ClassWithSSQLS.o:(.data+0x8): first defined here
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 3 seconds)
0 errors, 0 warnings
 

Here are the files.... does anyone else get the same result?

// FILE main.cpp ///////////////////////////////////////

#include "ClassWithSSQLS.h"
int main()
{
    ClassWithSSQLS c;
    return 0;
}

// FILE ssqls.h //////////////////////////////////////////

#ifndef SSQLS_H
#define SSQLS_H

#include <mysql++.h>
#include <custom.h>

sql_create_2(   macro, 1, 0,
                unsigned int, id,
                unsigned int, key )
#endif

// FILE ClassWithSSQLS.h ////////////////////////////////////////////

#ifndef CLASSWITHSSQLS_H
#define CLASSWITHSSQLS_H

// H IS NOT OWNER BUT NEEDS TO HAVE macro IN SCOPE SO....
#include "ssqls.h" // << THIS LINE SPOILS THE PARTY :(

class ClassWithSSQLS
{
    public:
        ClassWithSSQLS();
        macro           macro_;
};

#endif

// FILE ClassWithSSQLS.cpp //////////////////////////////////////////

// THE CPP IS THE OWNER!
#include "ClassWithSSQLS.h"

ClassWithSSQLS::ClassWithSSQLS()
{
   macro m;
}

If anyone can shed any light.. thanks

Simon




Thread
Linking errors after moving to SSQLSs, macro problemSimon Pickles12 Dec
  • Re: Linking errors after moving to SSQLSs, macro problemWilliam F. Dowling12 Dec
Re: Linking errors after moving to SSQLSs, macro problemWarren Young12 Dec
  • Re: Linking errors after moving to SSQLSs, macro problemSimon Pickles16 Dec
Re: Linking errors after moving to SSQLSs, macro problemWarren Young17 Dec
  • Re: Linking errors after moving to SSQLSs, macro problemSimon Pickles17 Dec
Re: Linking errors after moving to SSQLSs, macro problemWarren Young17 Dec
  • Re: Linking errors after moving to SSQLSs, macro problemSimon Pickles17 Dec
RE: Linking errors after moving to SSQLSs, macro problemJoel Fielder17 Dec
  • Re: Linking errors after moving to SSQLSs, macro problemDrew M.18 Dec
  • Re: Linking errors after moving to SSQLSs, macro problemSimon Pickles18 Dec
  • Re: Linking errors after moving to SSQLSs, macro problemWarren Young18 Dec
    • Re: Linking errors after moving to SSQLSs, macro problemJim19 Dec
      • Re: Linking errors after moving to SSQLSs, macro problemWarren Young19 Dec
        • Re: Linking errors after moving to SSQLSs, macro problemJim20 Dec
          • Re: Linking errors after moving to SSQLSs, macro problemWarren Young21 Dec
Re: Linking errors after moving to SSQLSs, macro problemWarren Young18 Dec
  • Re: Linking errors after moving to SSQLSs, macro problemWarren Young18 Dec
    • Re: Linking errors after moving to SSQLSs, macro problemSimon Pickles18 Dec
Re: Linking errors after moving to SSQLSs, macro problemWarren Young18 Dec