繁体   English   中英

C++ 有助于理解低级代码的语法

[英]C++ help to understand syntax of low level code

我正在阅读一些代码,发现很难理解这一点:

extern "C" NTSYSAPI NTSTATUS NTAPI ObReferenceObjectByName

这里有一些真实的代码:

extern "C" NTSYSAPI NTSTATUS NTAPI ObReferenceObjectByName(
            PUNICODE_STRING ObjectName,
            ULONG Attributes,
            PACCESS_STATE AccessState,
            ACCESS_MASK DesiredAccess,
            POBJECT_TYPE ObjectType,
            KPROCESSOR_MODE AccessMode,
            PVOID ParseContext OPTIONAL,
            PVOID * Object
        );

after searching for a while I figured out that the extern "C" is an instruction for the compiler, which resolves functions names like in C, and this three NTSYSAPI, NTSTATUS, NTAPI belong to winwdows kernel API, but I don't understand how正是这种语法有效,因为看起来有 3 个返回类型毫无意义,所以它们是某种预处理器注释,如 java? 或者可能是 (SAL) Microsoft 源代码注释语言。

话虽如此,这里的问题是,这种语法是标准 c++ 语言的一部分,还是只是 microsowft 在编译器中添加的某种额外功能,应该如何阅读? 谢谢

只有一种返回类型NTSTATUS ,它是一个枚举。 The others are modifiers on the function call, for example NTAPI resolves to __stdcall , which modifies how the function is called by the compiler, and NTSYSAPI to declspec(dllimport) , which marks the function as a library import.

这也与 SAL 无关。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM