variables corrupted

D

Dave Cullen

I have a VS 2005 C++ console application supporting MFC. Something's
happened since my last edit (it was working) and now I'm seeing corrupted
variables and Intellisense doesn't even recognize them. For instance in the
main function, if I Quickwatch nRetCode the IDE says error CX0017 symbol not
found.

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit:):GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
////////////////////////////////////
// Begin application here
}
}

This is right at the beginning of the program, before any function calls
that I make. The only other code in the main module is a few function
declarations and #includes. I've commented everything else out. Is there any
way to figure out what's going on without starting a new project and adding
all the source one cpp at a time until it breaks again?

Thanks
 
B

Bo Persson

Dave said:
I have a VS 2005 C++ console application supporting MFC. Something's
happened since my last edit (it was working) and now I'm seeing
corrupted variables and Intellisense doesn't even recognize them.
For instance in the main function, if I Quickwatch nRetCode the IDE
says error CX0017 symbol not found.

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit:):GetModuleHandle(NULL), NULL, ::GetCommandLine(),
0)) {
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
////////////////////////////////////
// Begin application here
}
}

This is right at the beginning of the program, before any function
calls that I make. The only other code in the main module is a few
function declarations and #includes. I've commented everything else
out. Is there any way to figure out what's going on without
starting a new project and adding all the source one cpp at a time
until it breaks again?
Thanks

The Intellisense database sometimes gets corrupted. Shit happens!

Close the environment, delete the .NCB file in the project directory,
and restart the IDE again. Intellisense will start from scratch, and
build a new .NCB file. Usually works much better than the old one.


Bo Persson
 
D

David Lowndes

I have a VS 2005 C++ console application supporting MFC. Something's
happened since my last edit (it was working) and now I'm seeing corrupted
variables and Intellisense doesn't even recognize them. For instance in the
main function, if I Quickwatch nRetCode the IDE says error CX0017 symbol not
found.

Are you debugging the release build?

Dave
 
B

Ben Voigt [C++ MVP]

Dave said:
I have a VS 2005 C++ console application supporting MFC. Something's
happened since my last edit (it was working) and now I'm seeing
corrupted variables and Intellisense doesn't even recognize them. For
instance in the main function, if I Quickwatch nRetCode the IDE says
error CX0017 symbol not found.

Close Visual Studio, delete .ncb, .bsc, .ilk, *.sbr, *.obj.

Open Visual Studio again and select "Rebuild All".

That will probably help your problem.
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit:):GetModuleHandle(NULL), NULL, ::GetCommandLine(),
0)) {
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
////////////////////////////////////
// Begin application here
}
}

This is right at the beginning of the program, before any function
calls that I make. The only other code in the main module is a few
function declarations and #includes. I've commented everything else
out. Is there any way to figure out what's going on without starting
a new project and adding all the source one cpp at a time until it
breaks again?
Thanks
 
D

Dave Cullen

David Lowndes said:

What an idiot I am. Yes, I was. Strange that VS 2005 didn't tell me that.
VC6 would have said there's no debug info...

Oops. Thanks.
Dave
 
D

David Lowndes

What an idiot I am. Yes, I was. Strange that VS 2005 didn't tell me that.
VC6 would have said there's no debug info...

With newer versions of VS, release build projects have debug info in
them, but as it's optimised you will see things like the curious
effects you had.

I'm glad it's sorted anyhow :)

Dave
 
R

Ron Francis

David Lowndes said:
With newer versions of VS, release build projects have debug info in
them, but as it's optimised you will see things like the curious
effects you had.

I'm glad it's sorted anyhow :)

Dave

Well picked Dave.

Regards,
Ron Francis
www.RonaldFrancis.com
 

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