Visual Studio Intellisense crashes due to macro file - visual-studio

In Visual Studio 2005, I have a .h file with preprocessor macros in it. They are apparently too complicated for Visual Studio's Intellisense because they make Visual Studio crash if they are present whereas it works fine if they are not. Does anyone know of a way to prevent Visual Studio parsing the file for Intellisense but still include it in the build. By the way, I have already tried the following:
Disabling Intellisense by renaming feacp.dll. Works, but impractical.
Visual Assist. Works, but $250.
Installing Visual Studio SP1 + the Intellisense hotfix (KB947315). Doesn't fix it (and ate 1GB of hard drive space).

The first thing to try is to install Visual Studio 2005 SP1. This fixes a lot of intellisense related issues which may help you out
http://msdn.microsoft.com/en-us/vstudio/bb265237.aspx
If that doesn't fix the problem try excluding the file from the project. This prevents it any any of it's contents from appearing in Visual Studio features (such as intellisense). If it's just a header file it shouldn't impact the build as the actual file won't be removed, it just won't be considered part of the project.

Ok, for the benefit of others, I'm going to solve this myself! I've been fiddling and the answer is as follows. If you have this problem, and you delete your ncb file to force Intellisense to update, you can prove to yourself that this works.
#ifdef out the offending code in your .h file as follows:
#ifdef SOMETHING_UNIQUE
<the offending code>
#endif
in the file that actually uses the macros (the cpp file that #includes the .h file):
#define SOMETHING_UNIQUE
Intellisense will now ignore the code in the .h file that causes it to crash (it will be greyed out in the editor), but it still gets compiled.

Related

Visual Studio 2019 not suggesting UE4 Libraries

Visual Studio 2019 stopped to suggest Unreal Engine 4 libraries. It used to suggest the names of the heather files I could include in the "name_of_the_new_class.h" file. It used to look like this:
desired state (not my personal screen but that how it used to work), now I get this current state. I reinstalled UE4 and revalidated Visual Studio how do I solve this if that issue is even solvable?
Manually typed in header files work and it will compile and work but why IntelliSense is not suggesting me this .h files?
Using <> instead of "" works and autocompletion works again.
https://caligari.dartmouth.edu/doc/ibmcxx/en_US/doc/complink/tasks/tuinclud.htm?fbclid=IwAR1YfI-BL1Ub8MW5GRVDV2iafLhaJx086d9IL_mn3XZVCbD0GRSzqAZ1MCw

Visual Studio 2013 tries to load localized afxres.rc from older version

We have recently upgraded an MFC solution from Visual Studio 2005 to Visual Studio 2013 (Update 4), at last. I think the solution originates in Visual Studio 6 and was upgraded to VS2003, then VS2005. It is a Multibyte (i.e. non Unicode) solution.
We haven't had many problems, so far. In fact it seemed like we had sorted pretty much everything out.
One of the errors we were getting was in the rc file, where the compiler said it couldn't find "l.esp\afxres.rc". Upon investigating the issue, we found that in VS2013 (I guess 2012 and 2010 too) the path is "l.esn\afxres.rc" so we changed it, and it all worked fine again.
Now, after "finishing" the port, we've continued the development, and we've found that, every time we make a change to the resources (add new controls, change the properties of existing ones) the path returns to the old one ("l.esp\afxres.rc"). It changes it when saving the resource file (make change, click save, it's already changed).
I guess there is some property, or something, that it's still telling the IDE it is a Visual Studio 2005 project, but I can't find it. I've tried removing the UpgradeFromVC71 property page, but to no avail.
Any ideas?
Ok, I've found it! Leaving an answer for future reference.
It's in the Resource include files. Go to Resource View, right click on the .rc file and select "Rsource Include Files". There are the offending includes. Change the path, and done!
https://support.microsoft.com/en-us/kb/198536 (old, but good enough)

VS 2012 Intellisense cannot open source file *.tlh - Intellisense not working

I am working on a big solution that contains a mix of C# and C++ code using Visual Studio 2012 Professional with the latest Resharper plugin.
I obtain a fresh copy of the entire solution from source control.
As expected, Intellisense places its curly red lines under many types and fields in C++ code before I compile my Solution for the first time. However now these squiggly lines do not disappear even after (successfully) compiling the entire solution.
I get 100+ Intellisense errors saying "Intellisense: cannot open source file .tlh
But these files definitely exist at the given location and VS has full access rights to them as I start it with elevated rights..
I am even able to jump into the namespaces, declarations or whatever with the red lines underneath so the code definitely exists.
How do I make Intellisense worke again and make these annoying lines disappear?

How to get rid of warning squiggles for WPP TraceEvent macro?

When using WPP in Visual Studio (2012) each occurence of TraceEvents(...) has a wavy underline and the help text is e.g.
#define TraceEvents WPP_(CALL)
error: identifier WPP_Call_Foo_cppNNN not defined
Well, it is defined, in the .tmh header file created by the WPP preprocessor and the project compiles just fine. But Visual Studio doesn't scan and/or recognize this file.
Is there a practical way of getting rid of those squiggles?
For now I work around the problem by putting
#ifdef __INTELLISENSE__
#undef TraceEvents
#define TraceEvents(a,b,...)
#endif
in one of the header files that are included after the .tmh in all of the files anyway.
The define __INTELLISENSE__ is mentioned in http://blogs.msdn.com/b/vcblog/archive/2011/03/29/10146895.aspx
Edit for Visual Studio 2012:
It appears you've reached the analysis limit of the preprocessor in Visual Studio 2012's IntelliSense engine. If you replace the TraceEvents reference with WPP_Call_Foo_cppNNN, it actually resolves the identifier without problems (until you rebuild the solution and the tmh header changes).
The solution is to load the solution in Visual Studio 2013, and choose to not upgrade the compiler toolchain, thus preserving backwards compatibility with Visual Studio 2012.
Previous Answer for Visual Studio 2013:
This was tested in Visual Studio 2013, so it may not apply to Visual Studio 2012. I couldn't find a release of the WDK that supports Visual Studio 2012, so you'll need to let me know how to configure the environment if the following steps do not work.
After building your project (to ensure the .tmh files exist), execute the Project → Rescan Solution command.
I also recommend you associate the files with the C++ editor through the following steps:
Open Tools → Options... → Text Editor → File Extension
Associate extension tmh with editor Microsoft Visual C++
Switch off the Live Semantic Errors in Options->Text Editor->C/C++ -> Advanced ...

Does compiler warnings cause intellisense to stop working?

I am using Visual Studio 2010 (c++), and Intellisense has stopped working. I've read that an error in the code can cause this, but my code compiles fine, I only have some warnings about a deprecated function, can this cause intellisense to stop working?
I tried deleting the .ncb file, but is not being regenerated. Also I read here that I have to make sure that stdafx.h is on the include path but I dont have stdafx.h on my project and I have used intellisense without it in the past.
I don't know what else I can do to try to make it work, any suggestions?
The IntelliSense parser was completely rewritten for VS2010. It no longer uses the .ncb file, it is now an .sdf file, a SQL Compact database. If you program in the C++/CLI language then you'll get no IntelliSense at all, the current implementation doesn't support that language. I've also seen feedback that C isn't well supported either yet.

Resources