473,785 Members | 2,823 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 NativeTypeNonPO D
{
public: virtual bool IsRenderable() { return false; }
};

#pragma managed
__gc class ManagedType
{
private: NativeTypePOD* m_nativePODType ;
private: NativeTypeNonPO D* m_nativeNonPODT ype;

public: ManagedType::Ma nagedType()
{
m_nativePODType = new NativeTypePOD() ;
m_nativeNonPODT ype = new NativeTypeNonPO D();
}

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

public: __property bool get_IsRenderabl eNonPOD()
{
bool retval = m_nativeNonPODT ype->IsRenderable() ;
return retval;
}

};

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

bool condition1 = mt1->IsRenderablePO D;
bool condition2 = mt1->IsRenderableNo nPOD;

System::Console ::WriteLine(S"T his first one works:");
System::Console ::WriteLine(S"C alling native bool non-virtual method hardwired
to return false : {0}", __box(condition 1));
System::Console ::WriteLine(S"\ nThis second one fails:");
System::Console ::WriteLine(S"C alling native bool virtual method hardwired
to return false : {0}", __box(condition 2));
}
Nov 17 '05 #1
1 1602
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**********@b entley.com> wrote in message
news:59******** *************** **@msnews.micro soft.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 NativeTypeNonPO D
{
public: virtual bool IsRenderable() { return false; }
};

#pragma managed
__gc class ManagedType
{
private: NativeTypePOD* m_nativePODType ;
private: NativeTypeNonPO D* m_nativeNonPODT ype;
public: ManagedType::Ma nagedType()
{
m_nativePODType = new NativeTypePOD() ;
m_nativeNonPODT ype = new NativeTypeNonPO D();
}
public: __property bool get_IsRenderabl ePOD()
{
bool retval = m_nativePODType->IsRenderable() ;
return retval;
}

public: __property bool get_IsRenderabl eNonPOD()
{
bool retval = m_nativeNonPODT ype->IsRenderable() ;
return retval;
}

};

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

bool condition1 = mt1->IsRenderablePO D;
bool condition2 = mt1->IsRenderableNo nPOD;
System::Console ::WriteLine(S"T his first one works:");
System::Console ::WriteLine(S"C alling native bool non-virtual method
hardwired to return false : {0}", __box(condition 1));
System::Console ::WriteLine(S"\ nThis second one fails:");
System::Console ::WriteLine(S"C alling native bool virtual method
hardwired to return false : {0}", __box(condition 2));
}

Nov 17 '05 #2

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

Similar topics

4
4129
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 symbols I am going to use from the wrapper library. The wrapper library has the code written that uses the native classes, and wraps them to present an equivalent of their interface for .NET.
5
1776
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 http://www.developersdex.com ***
10
2083
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 test function 125x more time to execute when the DLL is compiled with the /CLR parameter then when compiled without it. Average timings: -----------------------------
2
2323
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 struct "A" which is exported in the usual way. The first managed assembly defines a managed class "B" using the unmanaged class "A" defined in the unmanaged Dll. This class "B" has got a public
9
2075
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
1824
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 written in C# for testing every thing worked fine. Now I need to call the managed c++ class library through web service written in C#. When I call managed c++ methods from web service the code crashes on the line from where the native code starts(...
0
1221
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 one that built ok) & managed c++ = managed c++ dll step 2 results in this link error...
3
4711
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 application. Furthermore, I use a pointer to an unmanaged function to jump back into the managed dll. The managed part is basically a remoting enhancement which asynchronly
1
11328
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 its a managed implementation for a Virtual Studio Technology -VST- plugin). So I'm writing a thin C++ layer that does little more than marshal calls to the managed layer. In this scenario I need to call a managed method with an out parameter
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10153
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8976
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4053
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 we have to send another system
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.