Repository: cpputest/cpputest (cpp)

Issue:
old Visual C++ builds are broken.
#1808 broke the old Visual C++ builds in AppVeyor. I didn't notice when I opened the MR. Since it merged all pipelines are failing.

I don't have a Windows machine or know Visual C++ well enough to understand why it broke or how to fix it.

https://ci.appveyor.com/project/basvodde/cpputest/builds/50614045


Discussion:

Patch:
diff --git a/CppUTest.vcproj b/CppUTest.vcproj
--- a/CppUTest.vcproj
+++ b/CppUTest.vcproj
@@ -947,6 +947,10 @@
 				RelativePath=".\include\CppUTest\MemoryLeakDetector.h"
 				>
 			</File>
+			<File
+				RelativePath=".\include\CppUTest\MemoryLeakDetectorForceInclude.h"
+				>
+			</File>
 			<File
 				RelativePath=".\include\CppUTest\MemoryLeakDetectorMallocMacros.h"
 				>
diff --git a/CppUTest.vcxproj b/CppUTest.vcxproj
--- a/CppUTest.vcxproj
+++ b/CppUTest.vcxproj
@@ -271,6 +271,7 @@
     <ClInclude Include="include\cpputest\platformspecificfunctions_c.h" />
     <ClInclude Include="include\CppUTest\TeamCityTestOutput.h" />
     <ClInclude Include="include\CppUTest\MemoryLeakDetector.h" />
+    <ClInclude Include="include\CppUTest\MemoryLeakDetectorForceInclude.h" />
     <ClInclude Include="include\CppUTest\MemoryLeakDetectorMallocMacros.h" />
     <ClInclude Include="include\CppUTest\MemoryLeakDetectorNewMacros.h" />
     <ClInclude Include="include\CppUTest\MemoryLeakWarningPlugin.h" />
diff --git a/Makefile.am b/Makefile.am
--- a/Makefile.am
+++ b/Makefile.am
@@ -77,6 +77,7 @@ include_cpputest_HEADERS = \
 	include/CppUTest/CppUTestConfig.h \
 	include/CppUTest/JUnitTestOutput.h \
 	include/CppUTest/MemoryLeakDetector.h \
+	include/CppUTest/MemoryLeakDetectorForceInclude.h \
 	include/CppUTest/MemoryLeakDetectorMallocMacros.h \
 	include/CppUTest/MemoryLeakDetectorNewMacros.h \
 	include/CppUTest/MemoryLeakWarningPlugin.h \
diff --git a/include/CppUTest/MemoryLeakDetectorForceInclude.h b/include/CppUTest/MemoryLeakDetectorForceInclude.h
new file mode 100644
--- /dev/null
+++ b/include/CppUTest/MemoryLeakDetectorForceInclude.h
@@ -0,0 +1,4 @@
+// Not all toolchains support multiple force includes (namely IAR),
+// so we wrap the two in a single header.
+#include "MemoryLeakDetectorMallocMacros.h"
+#include "MemoryLeakDetectorNewMacros.h"
diff --git a/include/CppUTest/MemoryLeakDetectorNewMacros.h b/include/CppUTest/MemoryLeakDetectorNewMacros.h
--- a/include/CppUTest/MemoryLeakDetectorNewMacros.h
+++ b/include/CppUTest/MemoryLeakDetectorNewMacros.h
@@ -40,11 +40,15 @@
                 #undef strdup
                 #undef strndup
                 #undef CPPUTEST_USE_STRDUP_MACROS
+                #define CPPUTEST_REINCLUDE_MALLOC_MEMORY_LEAK_DETECTOR
             #endif
         #endif
         #include <new>
         #include <memory>
         #include <string>
+        #ifdef CPPUTEST_REINCLUDE_MALLOC_MEMORY_LEAK_DETECTOR
+            #include "MemoryLeakDetectorMallocMacros.h"
+        #endif
     #endif
 
     /* Some toolkits, e.g. MFC, provide their own new overloads with signature (size_t, const char *, int).
@@ -89,5 +93,3 @@
 #define CPPUTEST_USE_NEW_MACROS 1
 
 #endif
-
-#include "MemoryLeakDetectorMallocMacros.h"
diff --git a/platforms/iar/CppUTest.ewp b/platforms/iar/CppUTest.ewp
--- a/platforms/iar/CppUTest.ewp
+++ b/platforms/iar/CppUTest.ewp
@@ -262,8 +262,7 @@
         </option>
         <option>
           <name>IExtraOptions</name>
-          <state>--preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorNewMacros.h</state>
-          <state>--preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorMallocMacros.h</state>
+          <state>--preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorForceInclude.h</state>
         </option>
         <option>
           <name>CCLangConformance</name>
diff --git a/platforms/iar/CppUTestExt.ewp b/platforms/iar/CppUTestExt.ewp
--- a/platforms/iar/CppUTestExt.ewp
+++ b/platforms/iar/CppUTestExt.ewp
@@ -262,8 +262,7 @@
         </option>
         <option>
           <name>IExtraOptions</name>
-          <state>--preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorNewMacros.h</state>
-          <state>--preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorMallocMacros.h</state>
+          <state>--preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorForceInclude.h</state>
         </option>
         <option>
           <name>CCLangConformance</name>
diff --git a/platforms/iar/CppUTestExtTest.ewp b/platforms/iar/CppUTestExtTest.ewp
--- a/platforms/iar/CppUTestExtTest.ewp
+++ b/platforms/iar/CppUTestExtTest.ewp
@@ -262,8 +262,7 @@
         </option>
         <option>
           <name>IExtraOptions</name>
-          <state>--preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorNewMacros.h</state>
-          <state>--preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorMallocMacros.h</state>
+          <state>--preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorForceInclude.h</state>
         </option>
         <option>
           <name>CCLangConformance</name>
diff --git a/platforms/iar/CppUTestTest.ewp b/platforms/iar/CppUTestTest.ewp
--- a/platforms/iar/CppUTestTest.ewp
+++ b/platforms/iar/CppUTestTest.ewp
@@ -262,8 +262,7 @@
         </option>
         <option>
           <name>IExtraOptions</name>
-          <state>--preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorNewMacros.h</state>
-          <state>--preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorMallocMacros.h</state>
+          <state>--preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorForceInclude.h</state>
         </option>
         <option>
           <name>CCLangConformance</name>
diff --git a/src/CppUTest/CMakeLists.txt b/src/CppUTest/CMakeLists.txt
--- a/src/CppUTest/CMakeLists.txt
+++ b/src/CppUTest/CMakeLists.txt
@@ -39,6 +39,7 @@ add_library(CppUTest
         ${PROJECT_SOURCE_DIR}/include/CppUTest/TestFilter.h
         ${PROJECT_SOURCE_DIR}/include/CppUTest/TestTestingFixture.h
         ${PROJECT_SOURCE_DIR}/include/CppUTest/MemoryLeakDetectorNewMacros.h
+        ${PROJECT_SOURCE_DIR}/include/CppUTest/MemoryLeakDetectorForceInclude.h
         ${PROJECT_SOURCE_DIR}/include/CppUTest/TestHarness.h
         ${PROJECT_SOURCE_DIR}/include/CppUTest/Utest.h
         ${PROJECT_SOURCE_DIR}/include/CppUTest/MemoryLeakWarningPlugin.h
@@ -107,10 +108,7 @@ if(NOT CPPUTEST_MEM_LEAK_DETECTION_DISABLED)
     endif()
     target_compile_options(CppUTest
         PUBLIC
-            # Not all toolchains support multiple force includes (namely IAR),
-            # so C and C++ each get their own.
-            "$<$<COMPILE_LANGUAGE:C>:${force_include}CppUTest/MemoryLeakDetectorMallocMacros.h>"
-            "$<$<COMPILE_LANGUAGE:CXX>:${force_include}CppUTest/MemoryLeakDetectorNewMacros.h>"
+            ${force_include}CppUTest/MemoryLeakDetectorForceInclude.h
     )
 endif()
 


Test patch:
diff --git a/tests/AllTests.vcproj b/tests/AllTests.vcproj
--- a/tests/AllTests.vcproj
+++ b/tests/AllTests.vcproj
@@ -136,7 +136,7 @@
 				WarningLevel="3"
 				SuppressStartupBanner="true"
 				DebugInformationFormat="4"
-				ForcedIncludeFiles="CppUTest/MemoryLeakDetectorMallocMacros.h,CppUTest/MemoryLeakDetectorNewMacros.h"
+				ForcedIncludeFiles="CppUTest/MemoryLeakDetectorForceInclude.h"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"