Return value changed.

G

Guest

I have 2 modules, I am using .net dialog for user interface and unmanaged c++
for library. In library, I have a function that returns true or false. If I
call the function from managed code, I am getting true though the function is
returning false. The return value is changing.. am I missing something or
what is wrong.

Code is like this:

//managed code
{
...................
if(IsEnable())//I am getting true here.
{
...........do something.......
}
....................
}

//unmanaged code
bool IsEnable()
{
return false;//retuning false
}
 
J

Jochen Kalmbach [MVP]

Hi EHuq!
I have 2 modules, I am using .net dialog for user interface and unmanaged c++
for library. In library, I have a function that returns true or false. If I
call the function from managed code, I am getting true though the function is
returning false. The return value is changing.. am I missing something or
what is wrong.
//unmanaged code
bool IsEnable()
{
return false;//retuning false
}

I suggest you should return "BOOL" instead of "bool".

There is a known bug which (with special code) it will not marshal the
"bool" correctly...

See also: The virtual bool bug
http://www.codeproject.com/buglist/virtualboolbug.asp

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top