Project

General

Profile

Support #2174

Trouble running tutorial5.C

Added by Anonymous almost 9 years ago. Updated almost 9 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
Target version:
-
Start date:
09/04/2013
Due date:
% Done:

0%

Estimated time:

Description

I get these errors when working on tutorial5.C code:

Error  4   error C2766: explicit specialization; 'Wt::Dbo::dbo_traits<User>' has already been defined  c:\users\plug\documents\visual studio 2010\projects\st\stapp\main\source\model\user.h   25
...
Error   1   error C2908: explicit specialization; 'Wt::Dbo::dbo_traits<C>' has already been instantiated    c:\users\plug\documents\visual studio 2010\projects\st\stapp\main\source\model\user.h   21

They occur when I change this code in my User.h file:

namespace Wt {
  namespace Dbo {

  }
}

To this here:

namespace Wt {
  namespace Dbo {

    template<>
    struct dbo_traits<User> : public dbo_default_traits {


      static const char *surrogateIdField() { return 0; }
    };

  }
}

This doesn't make sense to me since the definition doesn't exist anywhere in my solution or include subfolders, as shown by these search results:

Find all "struct dbo_traits<User>", Subfolders, Find Results 1, "Visual C++ Include Directories"
  Matching lines: 0    Matching files: 0    Total files searched: 2668
...
Find all "struct dbo_traits<User>", Subfolders, Find Results 1, "Entire Solution"
  C:\Users\user\Documents\Visual Studio 2010\Projects\app\main\source\model\User.h(21):    struct dbo_traits<User> : public dbo_default_traits {
  Matching lines: 1    Matching files: 1    Total files searched: 30

It is only there once so how is it being defined and instantiated more than one time? These are the includes in my app.cpp which contains main():

...
#include <Wt/WAnchor>
#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WHBoxLayout>
#include <Wt/WCssStyleSheet>
#include <Wt/WLink>
#include <Wt/WText>
#include <Wt/WColor>
#include <Wt/WServer>
#include <Wt/Dbo/backend/Sqlite3>

#include "model/User.h"
#include "model/Post.h"
#include "model/Tag.h"
#include "model/Settings.h"

using namespace Wt;
using namespace std;

class User;
typedef Wt::Auth::Dbo::AuthInfo<User> AuthInfo;
...

And this from User.h:

...
#ifndef USER_
#define USER_

#include <Wt/WGlobal>
#include <Wt/Dbo/Dbo>
#include <string>

#include "Post.h"
#include "Settings.h"

namespace dbo = Wt::Dbo;

namespace Wt {
  namespace Dbo {
...

Also available in: Atom PDF