AssemblyInfo.cpp(1): warning C4005: '__CLR_VER' : macro redefinition || Slutprojekt.cpp(3): warning C4005: '__CLR_VER' : macro redefinition
Question
Monday, November 30, 2015 11:59 AM
I need help with the following error:
1> Build started: Project: Slutprojekt, Configuration: Debug Win32
1> AssemblyInfo.cpp
1>AssemblyInfo.cpp(1): warning C4005: '__CLR_VER' : macro redefinition
1> command-line arguments : see previous definition of '__CLR_VER'
1>AssemblyInfo.cpp(1): warning C4651: '/D__CLR_VER=40600127' specified for precompiled header but not for current compile
1>AssemblyInfo.cpp(1): fatal error C1093: API call 'ImportFile' failed '0x80070003' : ErrorMessage: Can't find the path. // translated from Swedish
1>
1> Description: Can't find the path.
1> HelpFile: complib.hlp
1> Slutprojekt.cpp
1>Slutprojekt.cpp(3): warning C4005: '__CLR_VER' : macro redefinition
1> command-line arguments : see previous definition of '__CLR_VER'
1>Slutprojekt.cpp(3): warning C4651: '/D__CLR_VER=40600127' specified for precompiled header but not for current compile
1>Slutprojekt.cpp(3): fatal error C1093: API call 'ImportFile' failed '0x80070003' : ErrorMessage: Can't find the path. //Translated from swedish.
1>
1> Description: Can't find the path.
1> HelpFile: complib.hlp
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
All replies (5)
Tuesday, December 1, 2015 7:05 AM ✅Answered
Hi,
Thanks for posting here.
>AssemblyInfo.cpp
1>AssemblyInfo.cpp(1): warning C4005: '__CLR_VER' : macro redefinition
1> command-line arguments : see previous definition of '__CLR_VER'
For this macro redefinition warning, it is clearly stated that the redefinition is caused by the previous definition.
See here, the possible causes for the redefinition are:
Defining a macro on the command line and in the code with a #define directive.
Macros imported from include files.
And the possible solutions are:
Remove one of the definitions.
Use an #undef directive before the second definition.
>AssemblyInfo.cpp(1): fatal error C1093: API call 'ImportFile' failed '0x80070003' : ErrorMessage: Can't find the path.
// translated from Swedish
1>
1> Description: Can't find the path.
1> HelpFile: complib.hlp
For this error, you may take a reference to this similar issue in link below. And have a try to clean and rebuild your solution.
The system cannot find the path specified
May
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.
Thursday, September 13, 2018 11:27 PM | 11 votes
I ran into this same problem today with our automated builds. Many of our .NET projects started to fail with an error like this. The previous answer marked as "solution" is incorrect.
Here is really what is going on and how to fix it:
__CLR_VER is defined at compile time as the value of the .NET runtime (mscorlib.dll). So when you build the project, the value of this macro is stored in your precompiled header file (myoutputfile.pch)
If something updates the .NET runtime with a newer dll, the value of __CLR_VER changes. So if you attempt a partial build (in which stdafx.cpp is not rebuilt), the value of __CLR_VER from the pch file and from the file you are trying to build will be different.
The solution is to delete the output folder, or update stdafx.h or do something else to cause a rebuild of all the files.
This is the most likely scenario:
1) you do a build today
2) tomorrow an automated windows update updates your mscorlib.dll
3) after this update, all your .NET projects will give this warning for partial builds:
warning C4651: '/D__CLR_VER=MMmmbbbb' specified for precompiled header but not for current compile
This means the pch file was created with mscorlib.dll version M.m.x.bbbb
Wednesday, October 10, 2018 11:39 PM
I just ran into the warning stated in the question. As I am using Visual Studio I was able to use "Rebuild Solution" off the "Build" ribbon. This fixed the warning for me. Thanks for the suggestion @silviubr
Monday, January 28, 2019 9:42 PM
@silviubr,
Thanks for the answer. I agree that the original answer is assuming the standard reasoning where someone redefines a macro that is within programmer control. In this case, for _CLR_VER, it seems to be the tools defining the macro based on either project settings and/or the .NET runtime as you stated.
The accepted answer really should be changed.
-Jonathan
Friday, January 24, 2020 6:33 PM
That was also my problem. Rebuild all fixed the warning. Thank you @silviubr!