Conversion to VS2008
-
I recently converted a project from VC++6 to Visual Studio 2008. The project is an unmanaged DLL using MFC. The problem I'm having is, when I run the project using Excel, using a tester I made to call the DLL and check return values, when the DLL should return false or true, based on certain calculations and conditions, the VS2008 project always returns true. Even using a "return false;" statement, the Excel tester gets a return value of true. In VC++6 it worked fine. Has anyone else seen this, or know of a way to fix it, or test futher to find the cause? Many Thanks!
The Code Demon Rises.
-
I recently converted a project from VC++6 to Visual Studio 2008. The project is an unmanaged DLL using MFC. The problem I'm having is, when I run the project using Excel, using a tester I made to call the DLL and check return values, when the DLL should return false or true, based on certain calculations and conditions, the VS2008 project always returns true. Even using a "return false;" statement, the Excel tester gets a return value of true. In VC++6 it worked fine. Has anyone else seen this, or know of a way to fix it, or test futher to find the cause? Many Thanks!
The Code Demon Rises.
Have you tried debugging the DLL from within Visual Studio (most likely by attaching to the tester, if it's a process, or Excel, if it's hosting the tester library) and seeing exactly what's going on behind the scenes?
Adam Maras | Software Developer Microsoft Certified Professional Developer
-
I recently converted a project from VC++6 to Visual Studio 2008. The project is an unmanaged DLL using MFC. The problem I'm having is, when I run the project using Excel, using a tester I made to call the DLL and check return values, when the DLL should return false or true, based on certain calculations and conditions, the VS2008 project always returns true. Even using a "return false;" statement, the Excel tester gets a return value of true. In VC++6 it worked fine. Has anyone else seen this, or know of a way to fix it, or test futher to find the cause? Many Thanks!
The Code Demon Rises.
Is it returning a BOOL or a bool? I'll wager the DLL returns a bool (a one byte value), but Excel is looking at the value as an int (a 4 byte value.) (The reason it may have "broken" is simply due to how the code was compiled between the two compilers since I've seen VC++ 6 display this behavior.)
-
Is it returning a BOOL or a bool? I'll wager the DLL returns a bool (a one byte value), but Excel is looking at the value as an int (a 4 byte value.) (The reason it may have "broken" is simply due to how the code was compiled between the two compilers since I've seen VC++ 6 display this behavior.)
To the first question, yes, that is why I built the Excel tester. That's how I know the 'return false;' statement does nothing. To the second question, I actually have several DLLs that return in the same way, and some of them still work, while some of them get stuck returning true. On the BOOL vs bool, in the C++ code it's a 'bool' and in the tester it's looking for a VBA 'Boolean'. Though with some of the DLLs working correctly, and the others not, I don't think that has anything to do with the bug.
A soft glow comes from the pit in the darkness. The clicking noise become faster - and louder. A wind begins to stir up from the pit, as the creature flexes it's wings, preparing for flight. You stare into the pit, and hear a voice say in your mind, "If you survive the encounter, declare it to the world." The Code Demon Rises.
-
To the first question, yes, that is why I built the Excel tester. That's how I know the 'return false;' statement does nothing. To the second question, I actually have several DLLs that return in the same way, and some of them still work, while some of them get stuck returning true. On the BOOL vs bool, in the C++ code it's a 'bool' and in the tester it's looking for a VBA 'Boolean'. Though with some of the DLLs working correctly, and the others not, I don't think that has anything to do with the bug.
A soft glow comes from the pit in the darkness. The clicking noise become faster - and louder. A wind begins to stir up from the pit, as the creature flexes it's wings, preparing for flight. You stare into the pit, and hear a voice say in your mind, "If you survive the encounter, declare it to the world." The Code Demon Rises.
I can't totally confirm this, but some sources state that a VBA Boolean is 4 bytes (another said it was 2 bytes).
-
I can't totally confirm this, but some sources state that a VBA Boolean is 4 bytes (another said it was 2 bytes).
-
A value is returned in the eax/ax/al register. Because a one byte bool only has to zero out the register al (xor al, al). The high bits of the [e]ax register may be set to a non-zero value.