- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
阅读 calling conventions 时有一个目的很明确的 thiscall
约定。
我知道 thiscall
定义了一个属于类的函数,因为这些函数需要一个对象作为非静态函数的第一个隐藏参数。
所以如果我没理解错的话,下面的函数应该是thiscall
。不需要使用关键字,因为编译器在那里没有太多选择,必须这样声明。
class Foo
{
public:
int function(void) { return 1; }
};
现在当我像这样在类外声明函数时:
int __thiscall Otherfunction(void) { return 1; }
int __thiscall Otherfunction(Foo *t) { return 1; }
然后我得到编译器错误:
error C3865: '__thiscall': can only be used on native member functions
它甚至是有道理的,因为您将如何调用这些函数?那么为什么不能使用这个关键字甚至存在呢?或者是否有一些可以/必须使用它的用例?
最佳答案
these functions require an object as their first hidden parameter for non-static functions
具有讽刺意味的是,你自己回答了一半,因为你在这里描述的是 fastcall
,而不是 thiscall
,这是一种调用成员函数的古老替代方法。 thiscall
将 this
存储在寄存器中,而不是堆栈中。
这就是你的答案,不是因为 thiscall
可以用在非成员函数上,而是因为你可以在成员函数上使用不同的约定(fastcall
当然还有 nakedcall
或者随便叫什么)。
关于c++ - __thiscall 关键字的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67321629/
我正在将 VC++6.0 项目转换为 Visual Studio 2008(到 2014 年)。我遇到了上述错误。 这是我的代码片段: BEGIN_MESSAGE_MAP(CImportProject
阅读 calling conventions 时有一个目的很明确的 thiscall 约定。 我知道 thiscall 定义了一个属于类的函数,因为这些函数需要一个对象作为非静态函数的第一个隐藏参数。
我正在使用 IDA Pro 6.3 对 Win32 .dll 进行静态分析,并且正在使用 Hex-Rays 反编译器和 IDA 反汇编器。我想了解这条线的作用。 v4 = (*(int (__this
我正在使用 boost::function 将函数传递给 Button 构造函数,以便它保存该函数。每当它被激活时调用它。 typedef boost::function Action; 在我的 Ti
我正在对一个旧的 C++ 代码进行逆向工程,我发现了一些我无法理解如何从普通的 C++ 代码中完成的东西。来自 DLL 的函数签名是一个可以恢复为 public: void __thiscall My
我收到链接器错误,我似乎无法找到根本原因,已检查是否包含 .cpp 文件并阅读其他论坛。 错误是: 1>------ Build started: Project: Penguin_RPG, Conf
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
我四处寻找试图解决这个错误的帖子,但在每种情况下我都已经按照他们的建议去做了。 我的编译输出: main.obj:-1: error: LNK2019: unresolved external sym
假设您需要在 x86 Windows 上 Hook /绕过一个 __thiscall 类型的函数,为了做到这一点,您需要将 void* 传递给 shim 函数。是的,这在技术上是对 C++ 的“可怕滥
因此,我创建了一个基本的 VC++ 程序,并创建了一个带有 1 个方法(除了构造函数和析构函数)的模板类。我收到以下错误: >main.obj : error LNK2019: unresolved
非常感谢任何帮助,我的前额被擦伤了。 我们有一个大的开源 DICOM库 ( dcmtk ) 我们用作静态库。它是非托管的 C++,我们从托管的 C++ DLL 链接到它。包裹它。它使用 CMake 来
我在 Bjarne“C++...”中实现了 String 类。我想要内联 read() 和其他访问器函数,所以我将它们标记为内联。没关系,但是定义对主文件中对类 String 的引用进行读取的哈希函数
我正在尝试 Hook 一个具有签名的未记录的函数: (void(__thiscall*)(int arg1, int arg2))0x6142E0; 我看过弯路示例“成员”,它解释了: By defa
我有一个类 template class LinkedListItem { public: LinkedListItem(T
假设我有这段代码是使用 HexRays 生成的。但是 __thiscall 似乎不能在 VC++ 6.0 中使用。 使用了非标准扩展:“__thiscall”关键字保留供将来使用 我如何在 VC++
我一直收到这个错误,它不允许我编译。谁能帮帮我? 这是用户名密码验证器.cpp #include "UsernamePasswordValidator.h" #include #include #
我正在使用 Visual Studio 2008。仅当使用 MFC CString(与 std::wstring 相比)构建包含静态链接库的项目时,我才收到链接器错误。 所以这是可行的: //head
我完全迷失了这一点。 编译的时候报错: Error 7 error LNK1120: 6 unresolved externals Error 4 error LNK2001: unresolved
当我调用 main() 函数时出现错误: 错误 2 error LNK2019: 函数“public: __thiscall Img::Img( int,int)"(??0?$Img@H@@QAE@H
好吧,我尝试通过网络寻找解决方案,但找不到任何解决我的问题的方法。 我正在为类编写作业,要求我们使用模板进行二叉树搜索。我已经在之前的类(class)中构建了一个整数二叉搜索树,所以这基本上是同一个程
我是一名优秀的程序员,十分优秀!