Skip to content

Compilation error using Conformance mode in VS2022 #339

@noujaimc

Description

@noujaimc

Hello,

during the upgrade of my project from Visual Studio 2019 to Visual Studio 2022, I encountered a compilation error related to the FakeIt library. Specifically, I’m using the single_header/mstest/fakeit.hpp header. When I enable conformance mode in VS2022, the following error occurs

C2440	'return': cannot convert from 'fakeit::MockingContext<void,const uint8_t [],int32_t,int32_t>' to 'fakeit::MockingContext<void,const uint8_t *,int32_t,int32_t>'		

Here is the code :

#include "pch.h"
#include "CppUnitTest.h"
#include "fakeit.hpp"

using namespace fakeit;
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace UnitTest
{
  class IClass
  {
     public:
       virtual void TestMethod(const uint8_t buffer[], int32_t offset, int32_t count) = 0;
       virtual ~IClass() = default;
   };
  
  TEST_CLASS(UnitTest)
  {
     public:
       TEST_METHOD(TestMethod1)
        {
	   Mock<IClass> mock;
           Fake(Method(mock, TestMethod));
        }
  };
}

fakeit

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions