gpt4 book ai didi

c++ - VC/C++裸属性有什么作用?

转载 作者:太空狗 更新时间:2023-10-29 23:31:25 25 4
gpt4 key购买 nike

From msdn

For functions declared with the naked attribute, the compiler generates code without prolog and epilog code. You can use this feature to write your own prolog/epilog code sequences using inline assembler code. Naked functions are particularly useful in writing virtual device drivers.

 __declspec(naked) declarator

什么是“prolog 和 epilog 代码”。我看到一个用 C 代码编写的库在仅使用 libc 的设备或固件上运行。它可以毫无问题地调用函数,naked 关键字的作用是什么以及为什么需要它?

注意:我不确定这些库中的函数使用什么调用约定。

最佳答案

Prolog:在函数体之前运行的代码,通常是处理函数输入和参数处理的代码。Epilog:在函数体之后运行的代码,通常是处理函数返回和返回值的代码。

有了“裸体”,你必须/有机会自己写这些东西。

关于c++ - VC/C++裸属性有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5030977/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com