Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Global SqlIds
Global SqlIds [message #46339] Sat, 23 April 2016 15:21 Go to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hello,

Is there a way to define global SqlIds to be used in different h and cpp files in the same project ? Confused

I have defined SqlIds in mainwindow header but I cannot use them in another window file which is used in main cpp.

Maybe a silly question Crying or Very Sad

Regards
Biobytes
Re: Global SqlIds [message #46537 is a reply to message #46339] Sat, 21 May 2016 19:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
Sure. You just have to follow c++ rules - declare extern in .h, then place definition in some .cpp.
Re: Global SqlIds [message #46553 is a reply to message #46537] Wed, 25 May 2016 14:10 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi Mirek,

Thank you for sending some time to reply to such obvious question Embarassed

My mistake was to make confusion with Pascal.

Sorry to insist but I have some difficulty with declaration of SqlId Sad

I tried this code in a IVDCommon.h header.

#ifndef _IVDCommon_IVDCommon_h
#define _IVDCommon_IVDCommon_h

extern SqlId DIRTBL,ALL,ID,PART,
      DIRINDEX,SUBINDEX,LIBELLE,
      NORMTBL,IDNORM,NORMTITLE,NORMTYPE,
      HARMONIZED,STATUS,NORMCODE,
      STATTBL,IDST,DESIGN,
      NORMTPTBL,IDTYPE,STANDTYPE,
      DEVTBL,IDDEVI,NAMEDEV,REFDEV,DESDEV,
      CLASSDEV,CONFDEV,AFFDEV,STATUSDEV,
      AFFTBL,IDAFF,NAMEAFF,IDSTD,IDDIR,
      DOCTBL,IDDOC,IDDEV,IDDIRD,NAMEDOC,DESDOC,TYPEDOC,
      HISTOTBL,IDH,IDDEVH,MODIF,DATEMODIF,RESPMODIF,
      CLASSTBL,IDCLAS,NAMECLASS,
      CONFTBL,IDCONF,NAMECONF,
      SIGNTBL,IDSIGN,LOGON,FIRSTNAME,LASTNAME,SIGNNAME;
#endif


For the cpp files, here is the example of the main cpp file (of course IVDCommon.h is added in main header Very Happy

IVDManager::IVDManager()
{
	CtrlLayout(*this, t_("Outil gestion Exigences Essentielles 16.03"));
	Icon(IVDImages::IvdMain);
	SetRect(10,10,GetScreenSize().cx-150,GetScreenSize().cy-100);
	CenterScreen().Sizeable().Zoomable();
	
	IvdBackImg.Set(IVDImages::IvdLogo);
		
	AddFrame(IvdMenuBar);
	AddFrame(IvdToolBar);
	AddFrame(TopSeparatorFrame());	
	
	IvdImageDisplay.setConnectionStatus(false);
	IvdImageInfoCtrl.Set(PaintRect(IvdImageDisplay));
	IvdStatusBar.AddFrame(IvdImageInfoCtrl.Left(30));
	IvdStatusBar.Set(0,t_("Pas de connexion en cours"),150);
	
	AddFrame(IvdStatusBar);
	AddFrame(BottomSeparatorFrame());
	
	IvdMenuBar.Set(THISBACK1(IvdSetMainMenu,false));
	WhenClose = THISBACK(IvdQuitApp);
	
	SqlId DIRTBL("DIRECTIVE"),ALL("*"),ID("ID"),PART("PART"),
      DIRINDEX("DIRINDEX"),SUBINDEX("SUBINDEX"),LIBELLE("LIBELLE"),
      NORMTBL("NORMES"),IDNORM("IDNORM"),NORMTITLE("NORMTITLE"),NORMTYPE("NORMTYPE"),
      HARMONIZED("HARMONIZED"),STATUS("STATUS"),NORMCODE("NORMCODE"),
      STATTBL("STATUSDES"),IDST("IDST"),DESIGN("DESIGNATION"),
      NORMTPTBL("NORMETYPE"),IDTYPE("IDTYPE"),STANDTYPE("STANDTYPE"),
      DEVTBL("DEVICES"),IDDEVI("IDDEV"),NAMEDEV("NAMEDEV"),REFDEV("REFDEV"),DESDEV("DESDEV"),
      CLASSDEV("CLASSDEV"),CONFDEV("CONFDEV"),AFFDEV("AFFDEV"),STATUSDEV("STATUSDEV"),
      AFFTBL("AFFECTATION"),IDAFF("IDAFF"),NAMEAFF("NAMEAFF"),IDSTD("IDSTD"),IDDIR("IDDIR"),
      DOCTBL("DOCUMENTS"),IDDOC("IDDOC"),IDDEV("IDDEV"),IDDIRD("IDDIR"),NAMEDOC("NAMEDOC"),DESDOC("DESDOC"),TYPEDOC("TYPEDOC"),
      HISTOTBL("HISTORIQUE"),IDH("IDH"),IDDEVH("IDDEV"),MODIF("MODIF"),DATEMODIF("DATEMODIF"),RESPMODIF("RESPMODIF"),
      CLASSTBL("CLASSES"),IDCLAS("IDCLAS"),NAMECLASS("NAMECLASS"),
      CONFTBL("CONFORMITY"),IDCONF("IDCONF"),NAMECONF("NAMECONF"),
      SIGNTBL("SIGN"),IDSIGN("IDSIGN"),LOGON("LOGON"),FIRSTNAME("FIRSTNAME"),LASTNAME("LASTNAME"),SIGNNAME("SIGNNAME");
}

GUI_APP_MAIN
{
	String LNGStr = Tokenize2(LNGAsText(GetSystemLNG())," ");
	SetLanguage(LNGFromText(LNGStr));
	SetLNGCharset(LNGFromText(LNGStr),CHARSET_UTF8);
	
	IVDManager().Run();
}


When building the project, the compiler complains that "DIRTBL,ID,PART,
DIRINDEX,SUBINDEX,LIBELLE,
NORMTBL,IDNORM,NORMTITLE,NORMTYPE,
HARMONIZED,STATUS,NORMCODE,
STATTBL,IDST,DESIGN,
NORMTPTBL,IDTYPE,STANDTYPE,
DEVTBL,IDDEVI,NAMEDEV,REFDEV,DESDEV,
CLASSDEV,CONFDEV,AFFDEV,STATUSDEV,
AFFTBL,IDAFF,NAMEAFF,IDSTD,IDDIR,
DOCTBL,IDDOC,IDDEV,IDDIRD,NAMEDOC,DESDOC,TYPEDOC,
HISTOTBL,IDH,IDDEVH,MODIF,DATEMODIF,RESPMODIF,
CLASSTBL,IDCLAS,NAMECLASS,
CONFTBL,IDCONF,NAMECONF,
SIGNTBL,IDSIGN,LOGON,FIRSTNAME,LASTNAME,SIGNNAME" are duplicated (!).

Sorry to bother you with this question but I am a bit lost

Regards
Biobytes
Re: Global SqlIds [message #46592 is a reply to message #46553] Sun, 05 June 2016 18:19 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
Strange, I would expect compiler to complain about them undefined, rather than duplicated (beacuse you have them just as local variables of constructor).
Re: Global SqlIds [message #46593 is a reply to message #46592] Sun, 05 June 2016 21:45 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hello Mirek,

Thank you for your reply. Error happens when linking. See the error message below.

IVDManager: 5 file(s) built in (0:41.60), 8321 msecs / file, duration = 43244 msecs, parallelization 0%
Linking...
LINK : D:\Installations\Compilateurs\upp\out\MyApps-bazaar\MSC15.Debug.Debug_Full.Gui.Mt.Mysqldll\IVDManager.exe not found or not built by the last incremental link; performing full link
IVDmain.obj : error LNK2005: "class Upp::SqlId DIRTBL" (?DIRTBL@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId ALL" (?ALL@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId ID" (?ID@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId PART" (?PART@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId DIRINDEX" (?DIRINDEX@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId SUBINDEX" (?SUBINDEX@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId LIBELLE" (?LIBELLE@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId NORMTBL" (?NORMTBL@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDNORM" (?IDNORM@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId NORMTITLE" (?NORMTITLE@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId NORMTYPE" (?NORMTYPE@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId HARMONIZED" (?HARMONIZED@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId STATUS" (?STATUS@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId NORMCODE" (?NORMCODE@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId STATTBL" (?STATTBL@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDST" (?IDST@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId DESIGN" (?DESIGN@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId NORMTPTBL" (?NORMTPTBL@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDTYPE" (?IDTYPE@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId STANDTYPE" (?STANDTYPE@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId DEVTBL" (?DEVTBL@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDDEVI" (?IDDEVI@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId NAMEDEV" (?NAMEDEV@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId REFDEV" (?REFDEV@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId DESDEV" (?DESDEV@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId CLASSDEV" (?CLASSDEV@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId CONFDEV" (?CONFDEV@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId AFFDEV" (?AFFDEV@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId STATUSDEV" (?STATUSDEV@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId AFFTBL" (?AFFTBL@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDAFF" (?IDAFF@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId NAMEAFF" (?NAMEAFF@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDSTD" (?IDSTD@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDDIR" (?IDDIR@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId DOCTBL" (?DOCTBL@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDDOC" (?IDDOC@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDDEV" (?IDDEV@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDDIRD" (?IDDIRD@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId NAMEDOC" (?NAMEDOC@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId DESDOC" (?DESDOC@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId TYPEDOC" (?TYPEDOC@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId HISTOTBL" (?HISTOTBL@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDH" (?IDH@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDDEVH" (?IDDEVH@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId MODIF" (?MODIF@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId DATEMODIF" (?DATEMODIF@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId RESPMODIF" (?RESPMODIF@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId CLASSTBL" (?CLASSTBL@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDCLAS" (?IDCLAS@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId NAMECLASS" (?NAMECLASS@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId CONFTBL" (?CONFTBL@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDCONF" (?IDCONF@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId NAMECONF" (?NAMECONF@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId SIGNTBL" (?SIGNTBL@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId IDSIGN" (?IDSIGN@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId LOGON" (?LOGON@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId FIRSTNAME" (?FIRSTNAME@@3VSqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId LASTNAME" (?LASTNAME@@3SqlId@Upp@@A) already defined in $blitz.obj
IVDmain.obj : error LNK2005: "class Upp::SqlId SIGNNAME" (?SIGNNAME@@3VSqlId@Upp@@A) already defined in $blitz.obj


Compiler is MSC15, Upp version 9896 and OS is Win 7.

Hope it can help

Regards
Biobytes
Re: Global SqlIds [message #46594 is a reply to message #46593] Mon, 06 June 2016 11:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
You must have something else messed that is not visible from code you have posted.

I have prepared simple demonstration for you. There are two additional tricks demonstrated:

- ID1 is 'plain and simple' raw C++ example. It 'renames' ID1 to represent different name.

- ID2 is similar but using SQLID macro so that you do not have to repeat the name of columns as string literal

- ID3, NAME, SURNAM are defined using 'multi-include' trick, means you just have to list ID in single place (ids.i file here)

Hope this help. If not, you are beyond help Smile

Mirek
  • Attachment: SqlIDS.zip
    (Size: 1.84KB, Downloaded 478 times)
Re: Global SqlIds [message #46598 is a reply to message #46594] Mon, 06 June 2016 21:39 Go to previous message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Thank you a lot Mirek for the examples.

I modify my code accordingly asap

Thx again Smile

Biobytes
Previous Topic: Sqlite and DUAL_PRIMARY_KEY
Next Topic: [solved]crash when execute sql command
Goto Forum:
  


Current Time: Fri Jun 21 23:19:11 CEST 2024

Total time taken to generate the page: 0.01167 seconds