Topaz Filer: if you use e-mail for business, we can save you money and decrease your risk.
Managed C++ and Unmanaged C++ and Inheritance
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vc.


Natalie Mitchell
Ok, I have a little problem here. I have a .NET application here that
I'm creating, and I want to link into a .lib of other classes (another piece
of code that I'm working on). The library is unmanaged, and contains an
extensive class hierarchy, single inheritance. The problem is that when I
want to declare an object of a type that is a child class in the unmanaged
code, it gives me a bunch of junk errors:

F:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\ObjIdl.h(245) : warning C4935: assembly access
specifier modified from 'public' F:\Program Files\Microsoft Visual Studio
..NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(257) : warning C4935: assembly
access specifier modified from 'public' F:\Program Files\Microsoft Visual
Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(7371) : error C2872:
'IDataObject' : ambiguous symbol could be 'F:\Program Files\Microsoft Visual
Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(245) :
System::Windows::Forms::IDataObject IDataObject' or 'stdafx.cpp(0) :
System::Windows::Forms::IDataObject' F:\Program Files\Microsoft Visual
Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(7385) : fatal error C1903:
unable to recover from previous error(s); stopping compilation

Note that IDataObject is not part of my class hierarchy. The class which I
am declaring an object of is derived publicly from a base class, and it
doesn't seem to matter if I change the access operators. Now If I declare a
an object of a type from the lib that is not derived, it doesn't give me
any errors at all.....What gives?

Reply to this message...
Vote that this is a GOOD answer...
 
Auto-following on Twitter
Ubuntu and XP on one “desktop”
 
    
Matthew Mitchell
One more thing...
It happens also when I simply include a header of a derived class, but
not when I include the header of a non derived class.

"Natalie Mitchell" <Click here to reveal e-mail address> wrote in message
news:#56AA7AeCHA.2556@tkmsftngp08...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
Outlook interop - stopping user properties appearing on Outlook message print
Seriously, why is “cut and paste” majorly newsworthy???
 
    
Matthew Mitchell
One more thing after that,

If I switch around the include order of the headers from
#include "cAboutBox.h"
#include "cMainForm.h"
#include "cEngineBase.h" - here's the culprit header

to

#include "cEngineBase.h" - here's the culprit header
#include "cAboutBox.h"
#include "cMainForm.h"

the old error goes away but the compiler complains it can't find function
GetObjectA in ResourceManager, and then stops compilation.

"Matthew Mitchell" <Click here to reveal e-mail address> wrote in message
news:eJZdx4TeCHA.2428@tkmsftngp11...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Visual C++ Team
GOOD ANSWER
Hello,

It's hard to diagnose this problem from your description. It looks like
it might be a name lookup issue. You might try removing any unnecessary
"using namespace" directives -- particularly ones in header files.If you'd
like, we could take a look at a preprocessed (command line options /P) file
to try and determine what's wrong.

Thanks.

--
Iain Bryson and Tanveer Gani
Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers no rights.

"Matthew Mitchell" <Click here to reveal e-mail address> wrote in message
news:uLZSF#TeCHA.1876@tkmsftngp10...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Matthew Mitchell
GOOD ANSWER
Ok, I did a little more poking around in my code. So far as I can tell,
it's a matter of naming as you said. I stuck in a reference to the
framework class MessageBox. As soon as I did so, even though I have using
namespace System::Windows::Forms; in the file, it complained that it
couldn't find the Show function. Further investigation showed me that if I
explicity reference the function
System::Windows::Forms::MessageBox::Show(...), it does not do so.
But any variables, even if they are explicity defined, like
System::Windows::Forms::MessageBox* m_ErrorBox, don't process when
attempting to call a function. I also tried making the class I am
referencing the libarary part of a namespace, but that seemed to make no
difference. Perhaps I need to make the base class a namespace also. Let me
know if you figure anything out.

I included the preprocessed files for the project. Note that the cNPC
intermediate file is actually part of a libarary that is included in the
solution as a project. The code might be a bit messy because of my messing
around as of late. Thanks in advance.

Matt

"Visual C++ Team" <Click here to reveal e-mail address> wrote in message
news:uTJyOdreCHA.1652@tkmsftngp09...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Visual C++ Team
Hi again,

It looks like the problem with GetObjectA is that the Windows headers
(wingdi.h line 3696) #define GetObject to GetObjectA. Unfortunately, there
is also a .NET class with a method of the same name. The best solution is to
keep your code that required Windows headers in a separate file than those
that use the .NET. Alternatively -- and this would be really ugly -- you
could #undef GetObject after the Windows headers but before you call the
GetObject method.

The other issues could also related to this.

--
Iain Bryson and Tanveer Gani
Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers no rights.

"Matthew Mitchell" <Click here to reveal e-mail address> wrote in message
news:Ox1ku62eCHA.2532@tkmsftngp09...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Matthew Mitchell
Ok thanks....i'm going to check my libarary for any wingdi.h includes. If I
can't find it, i'll just use the undef. I don't explcitly use wingdi
anywhere in my code right now.

"Visual C++ Team" <Click here to reveal e-mail address> wrote in message
news:#l2ute4eCHA.2424@tkmsftngp10...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
Email Archiving and Email Filing - what’s the difference?
Web-based task/todo list management
 
    
Matthew Mitchell
Thanks it worked. I just undefned Get Object after including my libary
headers. There was nothin I could do about wingdi and seperate headers.
The header I include includes d3d8.h, which in turn includes windows.h,
which in turn includes wingdi. There was no way to get around it.

"Natalie Mitchell" <Click here to reveal e-mail address> wrote in message
news:#56AA7AeCHA.2556@tkmsftngp08...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
Open source windows
The Law Society’s guidelines on e-mail management
 
 
System.Resources.ResourceManager
System.Windows.Forms.IDataObject
System.Windows.Forms.MessageBox




Ad
BootFX
Reliable and powerful .NET application framework.
Recession Busting Bespoke Software
Get through the recession by investing in bespoke software to decrease costs and create commercial opportunities.
Other DN247 Network Sites
.NET 247
SQL Server Wins
Old Skool Developer
 
Copyright © AMX Software Ltd 2008-2009. Portions copyright © Matthew Baxter-Reynolds 2001-2009. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - .NET 247 is a member of the DN247 Network - 4.0.30129.1734