Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with local classes? #326

Open
qqnnhhdmp opened this issue Jan 16, 2024 · 1 comment
Open

Not working with local classes? #326

qqnnhhdmp opened this issue Jan 16, 2024 · 1 comment
Labels

Comments

@qqnnhhdmp
Copy link

{ // In block scope:
  struct Callbacks {
      virtual ~Callbacks() = default;
      virtual auto on_ball_pocketed(nbs::eightball::BallId ball_id_) -> void = 0;
  };

  using namespace fakeit;

  Mock<Callbacks> mock_callbacks;
  When(Method(mock_callbacks, on_ball_pocketed)).Return();

  pool.on_ball_pocketed = [&mock_callbacks](auto &&_1) {
      return mock_callbacks.get().on_ball_pocketed(_1);
  };

  Verify(Method(mock_callbacks, on_ball_pocketed)).Exactly(1);
}

Error: error C3640: “CATCH2_INTERNAL_TEST_22::Callbacks::[thunk]: __cdecl void __cdecl CATCH2_INTERNAL_TEST_22(void)'::2'::Callbacks::`vcall'{8,{flat}}' }'”: 局部类的引用成员函数或虚拟成员函数必须进行定义

Translation of above chinese:

Reference member function or virtual member function of local class must be defined.

@FranckRJ
Copy link
Collaborator

FranckRJ commented Jan 17, 2024

https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-2/compiler-error-c3640?view=msvc-170

It looks like it's a limitation of MSVC (or C++ itself, I don't know). You can provide an empty definition for the function and it should work I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants