Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go to Definition Fails - Visual Studio 2008

I'm writing a C++ application in Visual Studio 2008. It has a lot of defined structures in several header files, such as:

#pragma pack( push , 1 )                // align on a 1-byte boundary

typedef struct myStruct_tag
{
    /* ... */
} myStruct_t;

#pragma pack( pop )                     // end 1-byte boundary alignment

In a source file, these defined structures are used as such:

void MyFunc( void )
{
    myStruct_t * myStruct = NULL;

    myStruct = (myStruct_t *)malloc( sizeof(myStruct_t) );

    /* and so forth and so on... */
}

Even though it successfully compiles with 0 errors and 0 warnings, sometimes when I right-click a custom data type (such as in MyFunc) it gives me an error:

The symbol 'myStruct_t' is not defined.

Then I click OK to close the dialog box and press Ctrl+Alt+F7 to rebuild the solution. It builds without any errors or warnings, so I know that it is finding the definition of myStruct_t when it compiles, but it cannot find it when I try to use the Go to Definition feature. The only thing that occurs to me is that this application has a lot of defined structures, single-byte aligned, but that shouldn't make a difference. Does anybody know how to fix this?

like image 981
Jim Fell Avatar asked Feb 08 '11 15:02

Jim Fell


2 Answers

Try closing your solution and then deleting the *.sdf file. When you reopen your solution Intellisense will be forced to rebuild its database and this might solve your problem.

Edit: Fixed mistake pointed

Edit 2: For legacy, in case you're using Visual Studio 2008 or older, you should delete all *.ncb files.

like image 179
Pepe Avatar answered Sep 28 '22 17:09

Pepe


  1. Terminate the visual studio process. (In visual studio 2005 one might need to delete all the *.ncb files when the visual studio process is killed)
  2. Reopen the solution and clean the solution: Build -> Clean Solution.
like image 28
0x90 Avatar answered Sep 28 '22 16:09

0x90