Intellisense in vs2010 with c++ - c++

I can't get intellisense to work. Even if I start with an empty project and add just one file to it with only an include for iostream and an int main() function that prints a char with cout (basically the most basic program), if I try to get intellisense to show anything (say by typing cout.) I get
IntelliSense: 'No additional information available' (See 'Troubleshooting IntelliSense in C++ Projects' for further help.)
Hours of googling have yielded a couple of articles over at the Microsoft sites that suggest a bunch of things to try or reasons why it wouldn't work. I have tried and eliminated them all, except for one that mentions that stdafx.h has to be in the path.
What is this file?
How do I know if it is in the path if I don't know where it is?
What does it have to do with IntelliSense?
Should I add this file to my project to get it to work?
Thank you.

I got it solved by the Microsoft team at http://connect.microsoft.com/VisualStudio/feedback/details/652838/intellisense-not-creating-ipch-folder
It had to do with a certain Windows Update installed on WinXP. The solution was to install VS2010_SP1 and then a certain update over it.

Look at this question :C++ VS Express 2010 Intellisense
It was solved by pressing CTRL+J .
EDIT: maybe it's the stdafx.h problem !
Add a file stdafx.cpp and a file stdafx.h to the project !
Use #include "stdafx.h" as yhe first line of code in all your .cpp files.
Include all rarely/never changing and frequently used header-files in stdafx.h.
Turn on precompiler-headers in your project and rebuild the project.
(Create a dummy project which have precompiled headers on to see how it's been done)

Do you use the /UseEnv switch when opening visual studio? It breaks Intellisense for c++ projects.

Please find *.sdf file (Intellisence database cache) in project directory and delete it and relaunch project solution this will bring back your intellisence.

There are a couple of threads about similar problems:
click on Help at VS2010 and look for Intellisense.
http://social.msdn.microsoft.com/Search/en-US?query=intellisense%20settings&refinement=123&beta=0&ac=1
http://social.msdn.microsoft.com/Forums/en/vswpfdesigner/thread/75c4cc8d-9a81-4bda-84f0-f619f7493b3b
stdafx.h should be added automatically when you create a New Project.
From the file:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently

Just throwing this out there, you are using namespace std? eg:
std::cout.
because intellisense wont work if it doesn't see cout
edit: I over looked that error message so this isn't the case but leaving the answer in case it might help someone down the line.

Maybe it never got installed, have you tried a repair install?, it's worth a shot..

I thought I should mention this:
In Visual Studio 2012 I noticed that Intellisense suddenly stopped working in my C++ project (same error as the poster described). This happened because I had added "DEBUG" as a Preprocessor definition under Project Properties -> C/C++ -> Preprocessor.
Once I removed it from that list and instead put it in the code ( #define DEBUG ) intellisense suddenly started working again.
I don't know why this happens, I just know it screws up my intellisense. I hope this helps someone.

WIN32;_WINDOWS;_DEBUG;Append _DEBUG;
remove Append _DEBUG;

baruch's answer worked for me. for completion, here is also the link to the VS2010-SP1:
http://www.microsoft.com/en-us/download/details.aspx?id=23691
so first installing this and then the hot-fix that baruch referred to solved me the problem, although the whole installation took almost 1:30 hour! (including one restart on my Win-XP machine.)

I know this is an old question, but I had a similar problem IntelliSense: 'No additional information available' (See 'Troubleshooting IntelliSense in C++ Projects' for further help.). My problem wasn't related with stdafx.h.
To solve my problem, I closed VS2010, deleted the .sdf and .suo files as well as the ipch directory inside the project's main folder.
Then I restarted VS2010, waited for it to build all its metadata again and Intellisense (autocompletion) worked nicely.
EDIT: I am not aware if this "maneuver" has negative side effects.

IntelliSense stores it's data in the SQL Server, which is installed during VS2010 setup. I recommend you check if the SQL Server Service is running.

Related

Visual Studio 2015: Intellisense string errors but solution compiles [duplicate]

We are currently evaluating the new Visual Studio 2015 and encountered a strange problem with IntelliSense. When I compiled our main solution with the new studio the build succeeds, but nevertheless 6 errors are shown.
I discovered that it's not a real error, but only an intellisense error. The code is definitely correct and everything compiled successfully. The code however is marked red and errors show up in the error list.
All 6 errors have the same origin. It's a simple constructor call. Strange enough, but there are also some occurrences of the exact same constructor without any errors.
The error message:
Code: CS1729
Message: '<the class>' does not contain a constructor that takes that many arguments.
Project: <the project name>
File: <the path to the file>
The new studio was installed on a freshly installed Windows 7 without any legacy software (no VS13).
I've already tried to clear the caches, deleted the suo file, deleted bin and obj directories, cleaned and rebuilt the solution etc. But nothing worked.
Can anyone explain that behavior to me?
I had thousands of intellisense errors and 0 build errors. After deleting .suo file and restarting VS intellisense errors are gone.
Suo file is located relatively to source in:
.vs\SolutionName\v14\.suo
According to comment: Beware that *.suo is a hidden file.
Edit: According to comments, VS2017 has the same issue, so you can use similar solution: Delete .vs\SolutionName\v15\.suo
VS2019 still has this issue. Delete .vs\SolutionName\v17\.suo
If deleting .suo still does solve your problem, then delete also all bin and obj directories in every project in the solution.
Also had this problem with a migrated project, so I referenced the Microsoft.CSharp dll. In some projects I needed to remove and add again the Reference in the project.
Ran into similar issue in Visual Studio 2017 ASP.Net Core Project. Following steps did the trick for me
Perform Clean Solution
Close VS
Delete .suo file & Delete bin/obj directories
Reopen VS
Similar problem as others, but different resolution. Posting in case I can help someone else.
Running Visual Studio 2017 15.5.2. I use Git and frequently switch branches. Several weeks ago, I started having editors show me errors (all related to types it could not find even though references were valid). Compile worked great. I confirmed the same issue in VS 2017 15.6 Preview (Jan 6, 2018). I would try to delete cache, SUO files, or bin/obj folders and no impact. At first it would appear to work. Reopen Visual Studio and everything would look good. Use "Rebuild Solution" and the IntelliSense errors would returns. I even tried uninstall/reinstall of Visual Studio.
I had the same issue on two machines, both with same version of Visual Studio.
By looking at the errors about missing types, they all appeared to come from two referenced projects. One of those references was a shared project used by just about every other project in the solution, but one of them was a small project without many references. It just so happens that the small project was also referenced by my larger shared project. In Visual Studio, I unloaded the small project and reloaded it. The errors went away! They errors did not come back on Rebuild Solution.
I then switched Git branches and the errors all came back. Fortunately I repeated the above steps of unloading/reloading the small project and the errors went away.
Every time I switch Git branches, the errors come back until I repeat that process. There are zero changes between the Git branches for the smaller project that I unload/reload. Unclear why that sequence is fixing my issue.
Also had this problem (the title, not the specific error message), as well as squiggly lines in the editor. The first squiggly line is under the first #include statement, which names a precompiled header. Intellisense fails to include the precompiled header, but doesn't list that as an error; instead it lists errors further down the file, on code that (very rightfully) relies on declarations in the precompiled header.
The reason Intellisense doesn't find the precompiled header in my environment is that the header named is not an actual file. It doesn't have to be in any other VC or gcc version I used, nor in the 2015 compiler, as long as the precompiled header settings are correctly configured. Apparently not any more for Intellisense. I'm not entirely sure it was different in 2013, maybe I just never noticed.
In the unlikely case that this would be the problem reported here, the solution is simple: create a small file with the pretend-name of the precompiled header, as specified in #include directives, and let that file include the actual name of the precompiled header.
If you wonder... why this distinction between the precompiled header name in the '#include' statement and the actual filename of the precompiled header? Precisely because it guarantees that precompiled header settings are correctly configured. Wherever a precompiled header is "#included", there is no file around that could be included. Either an actually precompiled (binary) version of the actual header is read, or the compilation fails. Obviously, a disadvantage is that it confuses people reading the code, not just Intellisense.
Visual Studio 2017
I have deleted ".suo" file from location .vs\SolutionName\v15.suo
And then restarted Visual studio. This worked for me.
Today I've had similar problem with MSVC++ 2015. I almost gave up and decided to go on without IDE hints, but suddenly I've noticed that stdafx.h of the project i had problems with doesn't contain any standard library headers. I've speculated that inclusion of all standard headers used in the project in stdafx.h might boost up compilation speed, however doing so fixed Intellisense errors as well.
In Visual Studio 2019 the problem is with changing branches with Git when there are NuGet packages installed in the project. What I did to solve this:
Clean Solution
Close Visual Studio
Delete the packages folder
Open Visual Studio
Go to Package Manager
Restore all packages
Recompile
If roslyn is missing, close and open Visual Studio, then recompile.
I had multiple stdfax.h in Additional Include Directories. Make sure the stdafx.h you intended is first in your path.
I had a similar issue with different Visual Studio versions.
Deleting the .suo or .vs folder did not help for me.
The Solution for me was, that I had the Extension StopOnFirstBuildError active. After turning off "Stop build on first error" in the build menu, and after the solution was fully built, the errors shown by Intellisense went away.
I was seeing the intellisearch errors only when publishing a website. (ASP/C# site, VS 2017). They broke the publish. Site ran fine locally.
Cleared the errors by unchecking the setting to pre-compile, and it published fine.
Publish -> Setting -> File Publish Options -> Precompile during publishing
I had this issue with a reference to another project. Removing and re-adding the project reference worked for me.

Visual Studio warning about copies of files with different contents

When I go to debug my C++ project in Visual Studio, up pops a little warning dialogue box that tells me:
A copy of datum.h was found in
c:/users/brad/desktop/source/binary/datum.h, but the current
source code is different from the version built into
c:/users/brad/desktop/source/binary/datum.h.
I'm having trouble understanding what this is even trying to tell me, let alone how to fix it. At first I thought it might be complaining that I'd accidentally duplicated a file in the directory, which I checked, and found nothing of the sort, which leaves me pretty stumped. I also tried excluding the file from the solution and adding it again, which didn't fix the problem either.
The warning doesn't appear to actually hinder the development of my project, but I suppose warnings exist for a reason, so if anyone knows what's gone wrong, any advice would be greatly appreciated. To my knowledge, I didn't change anything to cause the message to appear, it just popped up one time I went to debug the solution and has kept on appearing ever since.
Also, more copies of the same warning have started popping up, pertaining to other header files in my solution (I haven't recieved any about .cpp files yet, but it could be a coincidence, because it's only been going on for about 20 minutes).
Try removing breakpoints from the file in question.
This worked for me when it occurred with Visual Studio 2013 for a header file in debug build.
Source: Release mode file sync issue - current source code different from the version built
Additional notes: Clean / Rebuild also works, but that is painful for regularly changing code. Enabling the break point after starting debugger merely delays the message.
I solved it:
Close the window of the .h file in Visual Studio if it's open.
Close Visual Studio.
CUT the .h file from its normal location and paste it into a temporary folder that VS doesn't know about.
Restart VS and compile. It'll complain about the missing .h file. Good -- Make the bastard beg for it!
Paste the .h file back into its original location.
Compile. VS will gratefully accept the missing file. (Damn I hate Microsoft!)
This occurs if you rename an implementation file (*.c, *.cpp, etc.) to a header file.
This is because the Item Type still remains as C/C++ Source File, making it get compiled as a separate translation unit rather than as an actual header, preventing Visual Studio from recognizing its inclusion as a header elsewhere.
It took me quite a while to figure this out.
To fix this:
Right-click your header file in Solution Explorer and select Properties.
Select All Configurations, All Platforms.
Under General, change Item Type to C/C++ Header.
Press OK.
Force-recompile any file that #includes your header (or just Rebuild the solution).
The problem is that the debugger thinks that the checksum of the source file is different from what the compiler calculated and put in there. The debugger will then refuse to apply breakpoints in the files that mis-match, to prevent you from seeing data it can't guarantee is correct.
I have had this keep happening even after a clean rebuild. This is with VS 2015. My guess is perhaps the debugger and the compiler disagree on how to hash newlines or something like that? The fix is to turn off "require source files to exactly match the original version" in Debug -> Options -> Debugging -> General
Could you by any chance be debugging another executable (not the one actually built?). This is a common issue in scenarios where Visual Studio builds the binaries in one directory but then they are copied over to some other directory for debugging. I'd suggest you compare the target path under the debugging settings and the output directory under the general settings in Visual Studio.
This would explain the issue, since you are actually debugging some older version of the binary (not the one built currently) and thus the warning, since Visual Studio can't find the version of the source files for that version of the binary.
The reason may be circular header dependencies. datum.h may includes another_header.h (directly or indirectly), which includes datum.h.
I see the real reason of this question is not answered. So for someone still looking, here it goes...
The most common reason of this problem is that the source files used to build the existing obj files are different than the existing ones. In other words the
particular project did not build after new modifications to source. The solution to this problem is to rebuild the project after modifying.
This happened to me in situation where I had modified my static library projects files and then without building that project I started my application project which was using this static library project.
this worked for me:
close VS
delete *.vcxproj.filters file
restart VS
problem should be gone.
this worked for me:
clean project
debug/delete all breakpoints :)
This worked for me (as of March 2019):
Click the 'Build' drop-down menu in the top left of your Visual Studio window
Select 'Rebuild Solution'
I've changed the file name and it works now.
Just encountered this. In my case, one of my .h files contained implementation (a class with static methods), which was #included by one of my .cpp files, but the Project Settings were also telling Visual Studio to compile the .h file.
I manually edited both the .vcxproj and .vcxproj.filters project files, moving the .h file from the <ClCompile> ItemGroup to the <ClInclude> ItemGroup.
This did the trick for me; I never saw the "A copy of...is different from..." pop-up again.(Note that this was after I had thoroughly failed in attempts to get <DependentUpon> to work.)
My solutiion:
Build -> Configuration manager
Switch to another configuration (any, example Releas or Debug)
Switch to previous configuration
It is possible to have multiple projects, each with their own entry point within a solution. Make sure that the correct project is being run.
The source code is different message can appear in a project A's source when you are running project B. In this case, the message can mean This breakpoint won't be hit because you're running a project that doesn't include it

How to set Intellisense of Visual Studio2010 about c++? [duplicate]

I can't get intellisense to work. Even if I start with an empty project and add just one file to it with only an include for iostream and an int main() function that prints a char with cout (basically the most basic program), if I try to get intellisense to show anything (say by typing cout.) I get
IntelliSense: 'No additional information available' (See 'Troubleshooting IntelliSense in C++ Projects' for further help.)
Hours of googling have yielded a couple of articles over at the Microsoft sites that suggest a bunch of things to try or reasons why it wouldn't work. I have tried and eliminated them all, except for one that mentions that stdafx.h has to be in the path.
What is this file?
How do I know if it is in the path if I don't know where it is?
What does it have to do with IntelliSense?
Should I add this file to my project to get it to work?
Thank you.
I got it solved by the Microsoft team at http://connect.microsoft.com/VisualStudio/feedback/details/652838/intellisense-not-creating-ipch-folder
It had to do with a certain Windows Update installed on WinXP. The solution was to install VS2010_SP1 and then a certain update over it.
Look at this question :C++ VS Express 2010 Intellisense
It was solved by pressing CTRL+J .
EDIT: maybe it's the stdafx.h problem !
Add a file stdafx.cpp and a file stdafx.h to the project !
Use #include "stdafx.h" as yhe first line of code in all your .cpp files.
Include all rarely/never changing and frequently used header-files in stdafx.h.
Turn on precompiler-headers in your project and rebuild the project.
(Create a dummy project which have precompiled headers on to see how it's been done)
Do you use the /UseEnv switch when opening visual studio? It breaks Intellisense for c++ projects.
Please find *.sdf file (Intellisence database cache) in project directory and delete it and relaunch project solution this will bring back your intellisence.
There are a couple of threads about similar problems:
click on Help at VS2010 and look for Intellisense.
http://social.msdn.microsoft.com/Search/en-US?query=intellisense%20settings&refinement=123&beta=0&ac=1
http://social.msdn.microsoft.com/Forums/en/vswpfdesigner/thread/75c4cc8d-9a81-4bda-84f0-f619f7493b3b
stdafx.h should be added automatically when you create a New Project.
From the file:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
Just throwing this out there, you are using namespace std? eg:
std::cout.
because intellisense wont work if it doesn't see cout
edit: I over looked that error message so this isn't the case but leaving the answer in case it might help someone down the line.
Maybe it never got installed, have you tried a repair install?, it's worth a shot..
I thought I should mention this:
In Visual Studio 2012 I noticed that Intellisense suddenly stopped working in my C++ project (same error as the poster described). This happened because I had added "DEBUG" as a Preprocessor definition under Project Properties -> C/C++ -> Preprocessor.
Once I removed it from that list and instead put it in the code ( #define DEBUG ) intellisense suddenly started working again.
I don't know why this happens, I just know it screws up my intellisense. I hope this helps someone.
WIN32;_WINDOWS;_DEBUG;Append _DEBUG;
remove Append _DEBUG;
baruch's answer worked for me. for completion, here is also the link to the VS2010-SP1:
http://www.microsoft.com/en-us/download/details.aspx?id=23691
so first installing this and then the hot-fix that baruch referred to solved me the problem, although the whole installation took almost 1:30 hour! (including one restart on my Win-XP machine.)
I know this is an old question, but I had a similar problem IntelliSense: 'No additional information available' (See 'Troubleshooting IntelliSense in C++ Projects' for further help.). My problem wasn't related with stdafx.h.
To solve my problem, I closed VS2010, deleted the .sdf and .suo files as well as the ipch directory inside the project's main folder.
Then I restarted VS2010, waited for it to build all its metadata again and Intellisense (autocompletion) worked nicely.
EDIT: I am not aware if this "maneuver" has negative side effects.
IntelliSense stores it's data in the SQL Server, which is installed during VS2010 setup. I recommend you check if the SQL Server Service is running.

(Special case, might related to VC directory setting) fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory

I was bothered by the error
fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory
for quite a while, I tried my best to search all the relevant cases but couldn't find a good answer for me.
My situation is, I have a simple piece of code with a couple of dependencies to build, after setting up all the include folders, I'm just experiencing this compiler error all the time. Two weird questions I cannot answer,
There is another win32 console project somebody else set up for this project, working! I'm trying to copy all of his settings (the command line options are exactly the same, all env variables are same, and I run two projects on same visual studio), but just have this 1083 error in my own project.
I was playing around with the settings, one time I changed the platform from Active(Win32) to Win32, then suddenly the compiling works, but after that time I couldn't reproduce it any more.
The thing is, I'm guessing VS in my project might go to a wrong directory
C:\Program Files\Microsoft Visual Studio 8\VC\include instead of C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include
not quite sure, and earlier I was trying to compiling using a building script and make files, same error happened because there people didn't update the correct VS directory.
Sorry I couldn't provide the source code here, and it won't be helpful either since it has a couple of levels of dependency. But I hope based on my description some one might give some idea which direction should I go or spend time on.
iostream.h is deprecated, it should be just iostream:
#include <iostream>
See <iostream> vs. <iostream.h> vs. "iostream.h"
In this version of visual studio (and also in any modern C++ IDE) standard library headers are named without any suffices (iostream instead of iostream.h, string instead of string.h, etc)
Also, C library headers are named like cxxx instead of xxx.h, for example, you should include cstdlib instead of stdlib.h
When you say that you ran your project and the other person's (working) project on the "same visual studio", do you mean the same installation or the same version? If they're not on the same installation, then even if the project settings are copied exactly, it could be that the installation settings are different and that that's what's causing the problem. This may be a long shot, but I'll do my best to explain.
I came across your question because I had a slightly similar problem. Even without dependencies, I couldn't get a simple "Hello, World" program to compile. I used iostream without ".h" as many people suggested and still got C1083. Then I realized that when I installed VS, I unchecked one of the basic features, called "Visual C++ Run-Time Libraries". So I modified the installation to include this feature. Afterwards compilation proceeded successfully and the problem was solved. Is it possible that your installation is missing something that the other person has? If you can get your project to work on this other person's installation, then that might help to pinpoint the problem. Hope this helps. Good luck!
Does a simple hello world program that uses <iostream> compile and run fine?
If so, the Visual Studio system settings are fine and there is something probably wrong in either the project settings or the source.
You can eliminate the source by checking to make sure that the code is actually using #include <iostream> as opposed to #include <iostream.h>. Once that is done, make sure your header search paths point to the right place (the same as the default values in your hello world project for a start)

Visual C++ Build / Debugging Issue

I'm having a weird problem with Visual Studio. Whenever I change my code and build, even though I get the notification that the built was successful (and if any, it also shows errors in code and doesn't build) the executable is actually the previous build. This is getting really annoying and frustrating.
If I put a breakpoint on the new lines, the breakpoint gets disabled and it says
The breakpoint will not currently be hit. No executable code is
associated with this line. Possible causes include: preprocessor
directive or compiler/linker optimization
If I put a breakpoint on old lines of code, it stops processing but shows me this message
The source is different from when the module was built. Would you like
the debugger to use it anyway?
I never had this problem before and the source code in on my laptop's hard drive. It saves right away. The only way to get around this to Clean the entire solution manually every time, instead of basically pressing F5.
Thanks everyone for their suggestions. My mistake was that I defined the classes inside .cpp files, this somehow caused the linker to do weird (caching probably) stuff and link the old objects. I renamed the file to .h and everything's working as expected.
Perhaps your code is not built, or is built in a way you don't expect.
You might check by inserting a #error foobar preprocessor directive somewhere. If no error shows when building, you know you are in trouble!
But I never used Visual Studio (I'm only using Linux) so I cannot help more.
It might be that you have set main project some other project and building that.
make your project that you want to work on as "Main Project " by set main project available in menu bar.
I think you are using source files from another project (ex: if you are using a dll say, my.dll (which was built using some source files say, mycpp.cpp ); in your current project).
When you debugged into the file (mycpp.cpp), maybe you modified it.
Hence you need to rebuild the dll (my.dll) first in the project in which you created my.dll .
Or
Maybe you have opened a instance of mycpp.cpp in a window & debugging in another window.
you should rebuild the dll.
If you are not using files from another project, then I cant guess the cause...but still I would recommend using rebuild rather than clean & build.
please clarify your Question a bit.
#David expecting a reply from you...
I was looking for an answer to this issue since I was also stuck with it. A colleague of mine just gave me a solution that works. Yes, it seems really stupid, but it did the trick for me.
Our solution has many projects. He told me to select the project that I wish to break into and set it as the startup project (right-click on the project name and pick "Set as startup project"). I was desperate, so I tried. To my amazement, it works.
Since I have this window opened, I thought I'd share it in case someone else is stuck with the problem.
I faced the same problem. But reason was not as yours.
Then I just restarted the visual studio and it ran as expected.