error C2039: 'exception' : is not a member of '`global namespace'' 
Author Message
 error C2039: 'exception' : is not a member of '`global namespace''

I am trying to wrap a third party library in a namespace like this

newheader.hpp

namespace ThirdPary
{
        #include "thirdparty.h"

Quote:
}

Both VC++ 5 and VC++ 6 give me this error

:\program files\microsoft visual studio\vc98\include\exception(63) :
error C2039: 'exception' : is not a member of '`global namespace''
c:\program files\microsoft visual studio\vc98\include\exception(63) :
error C2873: 'exception' : symbol cannot be used in a using-declaration

Anyone out there seen this and know what its on about or know of a
solution.

Many thanks for your time.

Alastair.



Tue, 08 Jan 2002 03:00:00 GMT  
 error C2039: 'exception' : is not a member of '`global namespace''
[fu2 microsoft.public.vc.language]

Alastair Taylor a crit :

Quote:

> I am trying to wrap a third party library in a namespace like this

> newheader.hpp

> namespace ThirdPary
> {
>         #include "thirdparty.h"
> }

> Both VC++ 5 and VC++ 6 give me this error

> :\program files\microsoft visual studio\vc98\include\exception(63) :
> error C2039: 'exception' : is not a member of '`global namespace''
> c:\program files\microsoft visual studio\vc98\include\exception(63) :
> error C2873: 'exception' : symbol cannot be used in a using-declaration

> Anyone out there seen this and know what its on about or know of a
> solution.

  including the thirdparty header in a namespace has changed all the
names from f() to ThirdParty::f(). Maybe there is a function that wants
std::exception but that can't find it because it is just written
"exception" in the code, so the compiler tries to find
ThirdParty::exception?
  Just a guess.
--
__________________________________________________________



Tue, 08 Jan 2002 03:00:00 GMT  
 error C2039: 'exception' : is not a member of '`global namespace''
Quote:

> I am trying to wrap a third party library in a namespace like this

> newheader.hpp

> namespace ThirdPary
> {
>         #include "thirdparty.h"
> }

> Both VC++ 5 and VC++ 6 give me this error

 <snip>
Wrapping a library in a namespace is, unfortunately, not that simple.
Remember that the linker uses mangled names, and if you wrap the libs .h
file in a namespace, the linker won't find what it's looking for.

Furthermore, as Stanislas touched on, anything the thirdparty.h includes
also goes into the ThirdParty namespace, notably namespace std.
The line that the compiler complains about is

using ::exception;

and, of course, this exception is now not in the global namespace but in
your ThirdParty namespace.

What you'll have to do is wrap all the thirdparty functions in inline
functions in your ThirdParty namespace, and call these inlines. Classes
you'll have to wrap as well. Lots of work I guess, is it worth it?

You could also try to get the third party to do the work for you. After
all, now that namespaces do exist, each library should properly define
its own namespace(s).

--
Martin Fabian                         http://www.s2.chalmers.se/~fabian/
                                                                      --
"Cheer up. It may never happen"                          (Edina Monsoon)

        /* Remove NOSPAM from reply-to address to mail me */



Fri, 11 Jan 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. error C2039: 'exception' : is not a member of '`global namespace''

2. error C2039: 'CoInitializeEx' : is not a member of '`global namespace''

3. help 'CoCreateInstanceEx' : is not a member of '`global namespace''

4. 'const_iterator' : is not a member of '`global namespace''

5. error C2039: 'InlineIsEqualGUID' : is not a member of 'ATL'

6. error C2039: 'classCOaaPlotView' : is not a member of 'COaaPlotView'

7. 'Floating exception' run-time error

8. Help Needed with 'Unhandled Exception' error

9. InstallUtil 'Exception error, object expected'

10. error C2509: 'FinalConstruct' : member function not declared in 'CMYClass'

11. ERROR 2039: 'm_dwVersion' : is not a member of 'AFX_MODULE_STATE'

12. 'Command not found' ERROR

 

 
Powered by phpBB® Forum Software