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++ MT-multithreading and servers » Core/Inet.h -- unneeded "using namespace Upp"
Core/Inet.h -- unneeded "using namespace Upp" [message #50240] Sun, 02 September 2018 10:58 Go to next message
mdelfede is currently offline  mdelfede
Messages: 1259
Registered: September 2007
Senior Contributor
Hi,

at line 601 of Core/Inet.h there's an "using namespace Upp" which bring problems with some external libraries.
Can it be removed ? It's a bad practice to have "using namespace" in headers.

Ciao

Massimo
Re: Core/Inet.h -- unneeded "using namespace Upp" [message #50241 is a reply to message #50240] Sun, 02 September 2018 11:03 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 639
Registered: September 2012
Location: Poland, Kraków
Contributor
Hello,

It is already reported on our bug track - #1897 Smile

Moreover, I would like to inform you that NAMESPACE_UPP macro is depreicated and in your code you should use "namespace Upp {" instead. The same thing happens to "END_UPP_NAMESPACE" it should be replace with "}".

Your exemplary commit that is affected:
- https://github.com/ultimatepp/mirror/commit/a3dbcf6234190b26 e4f9da7c6df81728b5573832

Sincerely,
Klugier


Ultimate++ - one framework to rule them all.

[Updated on: Sun, 02 September 2018 11:06]

Report message to a moderator

Re: Core/Inet.h -- unneeded "using namespace Upp" [message #50242 is a reply to message #50241] Sun, 02 September 2018 11:34 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1259
Registered: September 2007
Senior Contributor
Ah, thank you Very Happy

As you're here... I still have problems with a name clash, but ONLY in Visual C. GCC does it correctly.

I've got a library that uses an 'IsEqual' function internally.
Upp uses the same 'IsEqual' in Upp namespace, in obsolete.h.

I removed ALL 'using namespace Upp' from my headers, but on Visual C the error is still there, saying that the
IsEqual call is ambiguous from Upp and the library's one, when instantiating a template.

Do you know if template istantiation does look at namespaces used AFTER includes ?

I mean :


#include <mylib.h>

using namespace Upp;

<instantiate some template in mylib.h which uses IsEqual function inside mylib.h>



IMHO it should NOT look at Upp::IsEqual... or yes ?

EDIT : I've also pre-processed my source, and I double checked that using namespace Upp is ONLY in the C++ file and AFTER all includes...

[Updated on: Sun, 02 September 2018 11:35]

Report message to a moderator

Re: Core/Inet.h -- unneeded "using namespace Upp" [message #50270 is a reply to message #50242] Fri, 07 September 2018 14:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
Define

"I've got a library that uses an 'IsEqual' function internally."

Smile Like in some inline or what?

Mirek
Re: Core/Inet.h -- unneeded "using namespace Upp" [message #50283 is a reply to message #50270] Wed, 12 September 2018 09:20 Go to previous message
mdelfede is currently offline  mdelfede
Messages: 1259
Registered: September 2007
Senior Contributor
Something as idiot as this one Very Happy

// ------------------------------------------------------------------
// IsEqual : Returns Standard_True if two integers are equal
// ------------------------------------------------------------------
inline Standard_Boolean IsEqual (const Standard_Integer theOne,
                                 const Standard_Integer theTwo)
{
  return theOne == theTwo;
}


I don't remember if this was the offending one, but that code is FULL with IsEqual inlines.
Even if I put the using namespace Upp directive AFTER all the includes of that library, usage in templates bring name clash.
I had to remove ALL namespace Upp usages and build a big include file that uses the Upp classes/functions I need.
In GCC it seems that the problem is not there.
BTW, when I use BLITZ the problem is there even on GCC, but that is normal.
Previous Topic: Windows authenticated web page load
Next Topic: Web page in U++ under IIS
Goto Forum:
  


Current Time: Mon Nov 18 02:34:26 CET 2019

Total time taken to generate the page: 0.03733 seconds