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 » Developing U++ » U++ Developers corner » How to manage UPP namespace
How to manage UPP namespace [message #43084] Sat, 03 May 2014 23:22 Go to next message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
This is a problem on which I stumble regularly.

Some packages are inside UPP namespace, some have they're own namespace, some don't have any namespace at all and some have 'using namespace Upp;' in they're headers !!
This leads to name clashes and ambiguous problems when using some packages or when including external resource code.

I think their should be some recommendations on how to correctly manage this (if you wan't you're package to be usable by others of coarse ), like the following:

  • always put code inside namespace Upp ( at least for classes meant to be used by other packages )
  • Never put 'using namespace xxx;' inside headers

[Updated on: Sat, 03 May 2014 23:24]

Report message to a moderator

Re: How to manage UPP namespace [message #43085 is a reply to message #43084] Sun, 04 May 2014 07:56 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Didier,

I agree that there should NEVER be "using namespace" in header that is meant to be used by others. I don't really care if some code is in Upp namespace and some in global, sometimes it is hard to tell whether it is really part of U++, e.g. for packages in bazaar, it is kind of blurry line.

Another related thing related to namespaces that I would like to point out is the existence of NONAMESPACE flag. It can be used to move all U++ code to global namespace, which might be preferable for someone who doesn't like to deal with "using namespace Upp;" in every file. But for this flag to work, all the code must use correct macros, defined in Core.h:
#ifdef flagNONAMESPACE
#define NAMESPACE_UPP
#define END_UPP_NAMESPACE
#define UPP
#else
#define NAMESPACE_UPP     namespace Upp {
#define END_UPP_NAMESPACE };
#define UPP               Upp
#endif

There is a lot of code (some even in Core IIRC), that does not follow this convention, making NONAMESPACE flag useless.

Best regards,
Honza
Previous Topic: Helper function to help dealing with GUI thread related issues
Next Topic: CodeEditor syntax support refactored
Goto Forum:
  


Current Time: Thu Mar 28 10:36:51 CET 2024

Total time taken to generate the page: 0.01103 seconds