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

虚函数打桩失败 #34

Open
xinxijishuwyq opened this issue Dec 7, 2022 · 3 comments
Open

虚函数打桩失败 #34

xinxijishuwyq opened this issue Dec 7, 2022 · 3 comments

Comments

@xinxijishuwyq
Copy link

EMOCK((bool (QFile::*)(QFile::OpenMode))&QFile::open)
.stubs()
.will(returnValue(true));

terminate called after throwing an instance of 'emock::Exception'
what(): Failed to get address of [(bool (QFile::*)(QFile::OpenMode))&QFile::open], maybe inlined or haven't been overridden in derived class.

@orca-zhang
Copy link
Contributor

是在Windows环境吗

@xinxijishuwyq
Copy link
Author

是在Windows环境吗

archlinux
gcc12.2.0
是不支持linux吗,还是我使用方法有问题

@xinxijishuwyq
Copy link
Author

xinxijishuwyq commented Dec 11, 2022

EMOCK((bool (*) (QFile*,QFile::OpenMode)) ((bool (QFile::*)(QFile::OpenMode))&QFile::open))
            .stubs()
            .will(invoke(mock_bar1));

参考了cpp-stub的做法,把成员函数指针强制转换成普通指针就好了--

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

No branches or pull requests

2 participants