Multimobile Development: Building Applications for any Smartphone
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...
 
Really good experience at the Apple Store
MonoDroid – looking *awesome*
 
    
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...
 
First volume of Multimobile Development nearly ready to go to press
A mention on Developing for the iPhone and Android: The pros and cons
 
    
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
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...
 
First chapters of Multimobile Development book now available on Apress Alpha program
iPad
 
    
Matthew Mitchell
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...
 
New book project – Multimobile Development: Building Applications for any Smartphone
Dive into HTML5
 
    
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...
 
Steve Jobs’ thoughtful/thought provoking Thoughts on Flash…
Handy list of countries in CSV format
 
    
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...
 
Really good experience at the Apple Store
MonoDroid – looking *awesome*
 
 
System.Resources.ResourceManager
System.Windows.Forms.IDataObject
System.Windows.Forms.MessageBox




Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Multimobile Development: Building Applications for any Smartphone
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734