Problem with old code, works under VC++ 6 but not VC 2005.
I have an old project for a DLL we use for Excel. When I build the project as
Release in Visual C++ 6 it works fine. But when I build the project in Visual
Studio 2005 it will not work. The problem I have is in the following code (I
have reduced the code to only include the interesting part):
#define rgFuncsRows 2
static LPSTR rgFuncs[rgFuncsRows][7] =
{ // Procedure type_text function_text argument_text
macro_type category shortcut_text
{" TEST1", " RR", " TEST1", " Arg",
" 1", " ABC", " "},
{" TEST2", " RR", " TEST2", " Arg",
" 1", " ABC", " "},
};
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
short i,j;
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
for (i=0; i<rgFuncsRows; i++)
{
for (j=0; j<7; j++)
{
rgFuncs[i][j][0] = (BYTE)lstrlen(rgFuncs[i][j] + 1);
}
}
}
return TRUE;
}
When I debug this code I get an Unhandled exception saying "Access violating
writing location 0xZZZZZZZZ" when the BYTE value is about to be written to
rgFuncs[i][j][0].
I can't figure out what's wrong, the code looks ok to me. And as I said
earlier, it works when building a release under VC++ 6 (Debug build under
VC++ 6 fails though).
Will be very thankful for help or tips on what may be wrong.