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 » Community » U++ community news and announcements » namespace agnostic layouts refactored
Re: namespace agnostic layouts refactored [message #58359 is a reply to message #58357] Sat, 07 May 2022 13:27 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
Klugier wrote on Sat, 07 May 2022 09:58
Hello Mirek,

It seems that with new approach Upp namespace is populated. Here is tutorial/Gui16b/main.cpp file that compiles fine and it shouldn't:
#include <CtrlLib/CtrlLib.h>

#define LAYOUTFILE <Gui16b/dlg.lay>
#include <CtrlCore/lay.h>

struct MyAppWindow : public WithDlgLayout<TopWindow> { // Upp:: prefix no longer need and it should...
	MyAppWindow() {
		CtrlLayout(*this, "MyDialog");
	}
};

GUI_APP_MAIN
{
	TopWindow top; // Upp:: prefix no longer required here...
	MyAppWindow().Run();
}


In context of placing anonymous namespace in header file, a lot of linters detect this as an warning. More info here. BTW, I compiled with CLANG and GCC. The second compiler produces a lot of warnings:
In file included from /home/klugier/upp/.cache/upp.out/tutorial/CtrlLib/GCC.Debug.Debug_Full.Gui.Shared/CtrlLib$blitz.cpp:238:
/home/klugier/upp/git/uppsrc/CtrlLib/PrinterJob.cpp:228:7: warning: 'Upp::PrinterDlg' has a base 'Upp::{anonymous}::WithPrinterLayout<Upp::TopWindow>' whose type uses the ano
    nymous namespace [-Wsubobject-linkage]
  228 | class PrinterDlg : public WithPrinterLayout<TopWindow> {
      |   

IMO, we shouldn't add this warning to the blacklist like we did for "-Wno-logical-op-parentheses" for Clang.

Can not we just follow old approach, but add new types (frames) like requested in #73? Anonymous namespace approach seems to have a lot of drawbacks.

Klugier


OK, the easiest thing to do is to go back for Upp:: for types (that is actually just CtrlLib.usc setting) and keep "using namespace Upp;" (inside functions Set_Layout) for values.

Any other idea? The ideal would be "using namespace Upp;" inside WithXXXLayout struct, but that is not valid C++...

Mirek

[Updated on: Sat, 07 May 2022 13:28]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: 2022.1
Next Topic: 2022.2rc1
Goto Forum:
  


Current Time: Wed Aug 06 18:36:22 CEST 2025

Total time taken to generate the page: 0.02841 seconds