I migrated c++ solution with multiple projects from VS2010 to VS2012.
Projects have reference of libraries with path set as System variables.
Application is getting compiled and run. But Intellisense reporting errors for all symbols and header in libraries. In External Dependencies node in solution explorer, it is not showing header files of 3rd Party libraries.
Headers file with hard coded and relative paths don't have this issue.
When right clicked on Header declaration to open header files, it shows all paths specified in project by striping environment variable values. e.g.
if include paths are "C:\QT\Includes;..\..\VISLIB\Inc;$(PROBAL_SHT_LIB)\V18.05\Inc", then it will show message "File 'XX.h" not found in ....... Build system path:
C:\QT\Includes;..\..\VISLIB\Inc;\V18.05\Inc.
and strips $(PROBAL_SHT_LIB).
Also noticed that if I set new system variable, then it is not shown in "Macros". or code is not getting compiled with VS2012. To make VS2012 recognize this variable. I need to restart PC.
This was working fine with VS2010.
You should know that the frontend/parser used by intellisense is not the same as that used by the actual compiler.
They are not always updated in sync and they often have different levels of feature completeness and different bugs. Thus it is not uncommon for intellisense to complain about perfectly valid code that the real compiler will handle just fine.
That is, of course, not great - but it is a fact and noone but Microsoft can do anything about it.
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
I've used Visual Studio's 'Code Maps' extensively for my C# projects in the past. I'm now working on a native c++ project and running into problems. When I add a class or method to a Code Map I get the following error message with no context or help available. Any ideas what the cause is?
Error Fail to get symbol's namespace
I should not that the project compiles and runs without a problem.
This MSDN page on Code Maps notes under Requirements that C++ has limited support.
Turns out it was my mistake and not a bug. I had incorrectly put includes in my headers such that almost all .cpp files included all .h files even if they weren't needed. It appears this caused the codemap application to crash. I went through and correctly included only the required .h files and correctly created my precompiled headers. This makes the codemap run as it should.
I probably misunderstand how the compilers work,but I have the following situation.I have a VC++ 2012 project.The project contains an API with hundreds of classes.Now, I create 'main' entry point file where I just use some std stuff.The main doesn't include even a single header from the API.Yet when I compile I see that pretty everything from the API is getting compiled into the executable?Why does it happen?Is it something I should configure in the project properties?
Source files that are part of the project are compiled also if "unused" through headers and references from your main routine.
If you don't want those compiled simply remove them from the project. The compiler might be able to optimize everything away but that doesn't mean they're not compiled if part of the project first.
In one Solution, I have two VC++ projects. Project A has linker inputs that are .obj files compiled by project B.
Visual Studio (2008) always tells me that project A is "out of date," and prompts me to ask if I want to rebuild it, every time I want to run/debug/build/etc. Even immediately after building the entire Solution: I do a successful full build, and then click Build again, and it wants to re-link Project A.
How can I prevent this from happening? Anyone understand what's going on here?
I think that the solution is to stop using .obj files from the other project. Instead, factor the code that is common to both A and B projects into own static library C and link both A and B to it.
I just had this problem with Visual Studio 2010 (both with and without SP1) and thanks to Ted Nugent I was able to fix it. The trick is to check whether all C++ header files listed in the project still exist, and remove the non-existing ones. Apparently this is a bug in the compiler.
Had something similar occur. I was working with code that used the system time and during the debug I was twiddling with it quite a lot. Somehow the files got some bad timestamps. In the build, it shows which files are getting recompiled, so I just opened each, forced a change (add space, delete a space) and then re-saved.
Similar to the old unix "touch".
In one project I had to do the same to its include files. But after 'touching' the files like that, the problem went away.