|
|
Home » U++ Library support » U++ SQL » Accessing Database from multiple files
Accessing Database from multiple files [message #21726] |
Tue, 02 June 2009 15:23  |
jeremy_c
Messages: 175 Registered: August 2007 Location: Ohio, USA
|
Experienced Member |
|
|
I am having a bit of problems coming up with either all my field names being either already defined:
main.obj : error LNK2005: "void __cdecl
TABLE_SUPPLIER(class Upp::SqlSchema &)"
(?TABLE_SUPPLIER@@YAXAAVSqlSchema@Upp@@@Z) already defined
in base_data.obj
Or not defined:
C:\Develop\Projects\UppApps\BeekPRO\base_data.cpp(8) :
error C2065: 'HIVE_TYPE' : undeclared identifier
What I have is BeekPRO.h (only revelant portions):
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
#define MODEL <BeekPRO/BeekPRO.sch>
#include <Sql/sch_schema.h>
#include <Sql/sch_header.h>
#include <Sql/sch_source.h>
I've tried moving the sch_source.h include from BeekPRO.h to BeekPRO.cpp thinking that the sch_header.h was just the definitions but sch_source.h was the actual source but that is not making a difference.
What I want is to be able to access the schema data from many .cpp files, thus, I can take an application that is getting more complex every minute and break it into smaller manageable files:
* BeekPRO.cpp - main file
* Apiary.cpp - Add/Edit/Remove apiaries
* Hive.cpp - Add/Edit/Remove hives
* Supplier.cpp - Add/Edit/Remove suppliers
* ... etc ...
Jeremy
|
|
|
|
Re: Accessing Database from multiple files [message #45110 is a reply to message #21727] |
Wed, 02 September 2015 17:03   |
 |
ratah
Messages: 107 Registered: July 2010
|
Experienced Member |
|
|
Hi everyone,
I have this redefinition problem. Trying to do like this:
--- main.cpp ---
#include <Core/Core.h>
using namespace Upp;
#include "classBOOK.h"
#include "classBORROW.h"
CONSOLE_APP_MAIN
{
}
--- sqlheader.h --
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
#define MODEL <testsql/schema1.sch>
#include "Sql/sch_header.h"
--- classBOOK.h ----
#include <Core/Core.h>
#include <plugin/sqlite3/Sqlite3.h>
using namespace Upp;
#include "sqlheader.h"
class CBook
{
CBook();
};
--- classBOOK.cpp ----
#include "classBOOK.h"
#include "Sql/sch_source.h"
#include "Sql/sch_schema.h"
CBook::CBook(){}
--- classBORROW.h ---
#include <Core/Core.h>
#include <plugin/sqlite3/Sqlite3.h>
using namespace Upp;
#include "sqlheader.h"
class CBorrow
{
CBorrow();
};
--- classBORROW.cpp ---
#include "classBORROW.h"
#include "Sql/sch_source.h"
#include "Sql/sch_schema.h"
CBorrow::CBorrow(){}
I get this error
Quote:
In file included from D:\upp\uppsrc/Sql/sch_model.h:162:0,
from D:\upp\uppsrc/plugin/sqlite3/Sqlite3Schema.h:95,
from D:\upp\uppsrc/Sql/sch_header.h:38,
from D:\MyApps\testsql\sqlheader.h:3,
from D:\MyApps\testsql\classBORROW.h:8,
from D:\MyApps\testsql\testsql.cpp:5:
D:\MyApps/testsql/schema1.sch:1:1: error: redefinition of 'struct S_BOOK'
In file included from D:\upp\uppsrc/Sql/sch_model.h:162:0,
from D:\upp\uppsrc/plugin/sqlite3/Sqlite3Schema.h:95,
from D:\upp\uppsrc/Sql/sch_header.h:38,
from D:\MyApps\testsql\sqlheader.h:3,
from D:\MyApps\testsql\classBOOK.h:8,
from D:\MyApps\testsql\testsql.cpp:4:
D:\MyApps/testsql/schema1.sch:1:1: error: previous definition of 'struct S_BOOK'
In file included from D:\upp\uppsrc/Sql/sch_model.h:162:0,
from D:\upp\uppsrc/plugin/sqlite3/Sqlite3Schema.h:95,
from D:\upp\uppsrc/Sql/sch_header.h:38,
from D:\MyApps\testsql\sqlheader.h:3,
from D:\MyApps\testsql\classBORROW.h:8,
from D:\MyApps\testsql\testsql.cpp:5:
D:\MyApps/testsql/schema1.sch:7:1: error: redefinition of 'struct S_BORROW_RECORD'
In file included from D:\upp\uppsrc/Sql/sch_model.h:162:0,
from D:\upp\uppsrc/plugin/sqlite3/Sqlite3Schema.h:95,
from D:\upp\uppsrc/Sql/sch_header.h:38,
from D:\MyApps\testsql\sqlheader.h:3,
from D:\MyApps\testsql\classBOOK.h:8,
from D:\MyApps\testsql\testsql.cpp:4:
D:\MyApps/testsql/schema1.sch:7:1: error: previous definition of 'struct S_BORROW_RECORD'
testsql: 3 file(s) built in (0:03.65), 1217 msecs / file, duration = 3719 msecs, parallelization 73%
There were errors. (0:03.75)
Do someone can help me please to avoid redefinition.
Thanks in advanced
|
|
|
Re: Accessing Database from multiple files [message #45116 is a reply to message #45110] |
Fri, 04 September 2015 17:23  |
|
Hi ratah,
I think your problem is that you include Sql/sch_schema.h as well. Look at it's source, you'll see that it only includes sch_header.h and sch_source.h. You should use either only sch_schema.h (usually useful only when all your sql related code is in single cpp file) or sch_header.h in your header files and sch_source.h in exactly one of your cpp files.
Best regards,
Honza
|
|
|
Goto Forum:
Current Time: Fri May 09 20:23:35 CEST 2025
Total time taken to generate the page: 0.02237 seconds
|
|
|