开发者

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开发者_JS百科 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?


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.


  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.


For me the only thing that worked in Visual Studio 2005 was to change to Release, do Rebuild Solution (which failed as the Release project was not correctly set up yet) then switch back to the Debug configuration and do Rebuild Solution. After this "Go To Definition" worked again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜