Home » U++ Library support » U++ SQL » SQL tutorial 5 and using namespace Upp; in header file (Solved)
|
Re: SQL tutorial 5 and using namespace Upp; in header file (Solved) [message #52805 is a reply to message #52791] |
Sat, 30 November 2019 05:14 |
coolman
Messages: 114 Registered: April 2006 Location: Czech Republic
|
Experienced Member |
|
|
Hi,
The solution is simple - in the header and source file enclose include and definitions related to SQL into block "namespace Upp". And move command "using namespace Upp;" from header file to source file.
MyApp.h
#ifndef _MyApp_h_
#define _MyApp_h_
#include <Core/Core.h>
#include <plugin/sqlite3/Sqlite3.h>
namespace Upp {
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
#define MODEL <Sql05/MyApp.sch>
#include "Sql/sch_header.h"
}
#endif
main.cpp
#include "MyApp.h"
using namespace Upp;
namespace Upp {
#include <Sql/sch_schema.h>
#include <Sql/sch_source.h>
}
CONSOLE_APP_MAIN
{
....
[Updated on: Sat, 30 November 2019 05:14] Report message to a moderator
|
|
|
Re: SQL tutorial 5 and using namespace Upp; in header file (Solved) [message #52806 is a reply to message #52805] |
Sat, 30 November 2019 12:12 |
|
Klugier
Messages: 1075 Registered: September 2012 Location: Poland, Kraków
|
Senior Contributor |
|
|
Hello coolman,
Nice catch! I think for the visibility reasons we should use following notation:
MyApp.h
#ifndef _MyApp_h_
#define _MyApp_h_
#include <Core/Core.h>
#include <plugin/sqlite3/Sqlite3.h>
namespace Upp
{
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
#define MODEL <Sql05/MyApp.sch>
#include "Sql/sch_header.h"
}
#endif
MyApp.cpp:
#include "MyApp.h"
namespace Upp
{
#include <Sql/sch_schema.h>
#include <Sql/sch_source.h>
}
using namespace Upp;
CONSOLE_APP_MAIN
{
Wit additional level of indent the construction is much more visible. In my opinion "using namespace Upp" should be used after include block to not interfere with includes.
Sincerely,
Klugier
U++ - one framework to rule them all.
[Updated on: Sat, 30 November 2019 12:12] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu Mar 28 13:54:14 CET 2024
Total time taken to generate the page: 0.01030 seconds
|