Visual Studio warning about copies of files with different contents

前端 未结 13 770
北恋
北恋 2021-02-05 00:05

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/sou         


        
相关标签:
13条回答
  • 2021-02-05 00:25

    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.

    0 讨论(0)
  • 2021-02-05 00:26

    I've changed the file name and it works now.

    0 讨论(0)
  • 2021-02-05 00:27

    This worked for me (as of March 2019):

    1. Click the 'Build' drop-down menu in the top left of your Visual Studio window
    2. Select 'Rebuild Solution'
    0 讨论(0)
  • 2021-02-05 00:32

    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:

    1. Right-click your header file in Solution Explorer and select Properties.

    2. Select All Configurations, All Platforms.

    3. Under General, change Item Type to C/C++ Header.

    4. Press OK.

    5. Force-recompile any file that #includes your header (or just Rebuild the solution).

    0 讨论(0)
  • 2021-02-05 00:34

    this worked for me:

    • close VS
    • delete *.vcxproj.filters file
    • restart VS

    problem should be gone.

    0 讨论(0)
  • 2021-02-05 00:36

    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

    0 讨论(0)
提交回复
热议问题