473,506 Members | 16,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VC 7.1 bug in IJW --- calling native virtual methods returning bool from managed code


What do you make of this? I cannot tell for sure but it almost seems as
the the transition thunk to get back from the native bool method to the managed
caller is looking at eax and, if any bit is set, normalizing it to 0x00000001.
If it wants to normalize the value then it should only operate on the al
register since that's all that the native bool method uses to hold the return
value.

Is this a known VC 7.1 bug? Is there a hotfix available?
//
// compile with VC 7.1 like this:
//
// cl /clr main.cpp
//

#using <mscorlib.dll>
#using <System.dll>

#pragma unmanaged
class NativeTypePOD
{
public: bool IsRenderable() { return false; }
};

class NativeTypeNonPOD
{
public: virtual bool IsRenderable() { return false; }
};

#pragma managed
__gc class ManagedType
{
private: NativeTypePOD* m_nativePODType;
private: NativeTypeNonPOD* m_nativeNonPODType;

public: ManagedType::ManagedType()
{
m_nativePODType = new NativeTypePOD();
m_nativeNonPODType = new NativeTypeNonPOD();
}

public: __property bool get_IsRenderablePOD()
{
bool retval = m_nativePODType->IsRenderable();
return retval;
}

public: __property bool get_IsRenderableNonPOD()
{
bool retval = m_nativeNonPODType->IsRenderable();
return retval;
}

};

int main(int argc, char* argv[])
{
ManagedType* mt1 = new ManagedType();

bool condition1 = mt1->IsRenderablePOD;
bool condition2 = mt1->IsRenderableNonPOD;

System::Console::WriteLine(S"This first one works:");
System::Console::WriteLine(S"Calling native bool non-virtual method hardwired
to return false : {0}", __box(condition1));
System::Console::WriteLine(S"\nThis second one fails:");
System::Console::WriteLine(S"Calling native bool virtual method hardwired
to return false : {0}", __box(condition2));
}
Nov 17 '05 #1
1 1584
It's a bug in VC 7.1
See http://www.voidnish.com/articles/Sho...virtualboolbug
Been fixed in Whidbey!

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
"Bern McCarty" <be**********@bentley.com> wrote in message
news:59*************************@msnews.microsoft. com...

What do you make of this? I cannot tell for sure but it almost seems as
the the transition thunk to get back from the native bool method to the
managed caller is looking at eax and, if any bit is set, normalizing it to
0x00000001. If it wants to normalize the value then it should only operate
on the al register since that's all that the native bool method uses to
hold the return value.

Is this a known VC 7.1 bug? Is there a hotfix available?
//
// compile with VC 7.1 like this:
//
// cl /clr main.cpp
//

#using <mscorlib.dll>
#using <System.dll>

#pragma unmanaged
class NativeTypePOD
{
public: bool IsRenderable() { return false; }
};

class NativeTypeNonPOD
{
public: virtual bool IsRenderable() { return false; }
};

#pragma managed
__gc class ManagedType
{
private: NativeTypePOD* m_nativePODType;
private: NativeTypeNonPOD* m_nativeNonPODType;
public: ManagedType::ManagedType()
{
m_nativePODType = new NativeTypePOD();
m_nativeNonPODType = new NativeTypeNonPOD();
}
public: __property bool get_IsRenderablePOD()
{
bool retval = m_nativePODType->IsRenderable();
return retval;
}

public: __property bool get_IsRenderableNonPOD()
{
bool retval = m_nativeNonPODType->IsRenderable();
return retval;
}

};

int main(int argc, char* argv[])
{
ManagedType* mt1 = new ManagedType();

bool condition1 = mt1->IsRenderablePOD;
bool condition2 = mt1->IsRenderableNonPOD;
System::Console::WriteLine(S"This first one works:");
System::Console::WriteLine(S"Calling native bool non-virtual method
hardwired to return false : {0}", __box(condition1));
System::Console::WriteLine(S"\nThis second one fails:");
System::Console::WriteLine(S"Calling native bool virtual method
hardwired to return false : {0}", __box(condition2));
}

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4097
by: David Kantowitz | last post by:
I am trying to wrap a native-C++ DLL in managed C++, to use in a .NET project. The native code is compiled into a DLL, and I have created a .def file that exports the mangled names of the...
5
1766
by: Virajitha Sarma | last post by:
Hi, Can u plz help me out with how to call a C# DLL from C... I tried to find out by searching in net..but i couldnot find anything on it.... Thanku Virajitha *** Sent via Developersdex...
10
2065
by: Gustavo L. Fabro | last post by:
Greetings! I've been porting an application for Builder to VS .NET 2003 and searching for possible bottlenecks (the application is currently running slow). I found out one scenario that takes a...
2
2303
by: Martin Zenkel | last post by:
Dear VS Team, using the Beta 2 of VS 2005 I've encontered the following problem. Let's assume threre are three Dll's, one unmanaged and two managed. In the unmanaged we put a simple unmanged...
9
2046
by: Herby | last post by:
Is possible to have a managed method within a Native(un-managed) class within a \clr project? E.g. class myClass { public: #pragma managed void myMethod(void);
2
1806
by: Haroon_Saeed | last post by:
Hey, I wrote a managed c++ class library in viusal studio 2005. This managed c++ dll calls native C++ methods of an SDK. When I referenced this managed c++ library in a console applciation...
0
1206
by: =?Utf-8?B?SmF5?= | last post by:
Hello, I'm running into a linking problem when trying to build a dll like so... step1: native C++ library & managed c++ = managed c++ dll (this one builds fine) step 2: managed c++ dll (the...
3
4683
by: Klaus | last post by:
Hi, I have an existing VC 6 MFC application which communicates asynchronly with a VC 2005 managed code dll. I use an unmanaged base class with virtual functions to access methods in the MFC...
1
11228
by: obiwanjacobi | last post by:
Hi there, This is probably a really dump question but I'm stuck and need a leg- up with this. I'm writing a C++ interop layer that couples a managed plugin to an unmanaged host (specifically...
0
7218
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.