Visual Studio warning about copies of files with different contents

前端 未结 13 769
北恋
北恋 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: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).

提交回复
热议问题