gpt4 book ai didi

c++ - SOMTEMPLATE_VR_API 是什么?

转载 作者:行者123 更新时间:2023-11-28 04:15:17 24 4
gpt4 key购买 nike

我在虚幻引擎 C++ vr 实现中发现了这个宏。有人可以解释这个宏的目标是什么吗?我应该什么时候使用这个宏?为什么我在虚幻引擎源中找不到这个宏?

UCLASS()
class SOMTEMPLATE_VR_API className :

最佳答案

_API 宏用于向其他模块公开类和函数。

来自documentation :

The easiest way to think about these specifiers is that they are used to tag functions, classes or data as public to your module's DLL file. If you mark a function in the Engine module as ENGINE_API, then any module that imports Engine can access that function directly.

These are only used when compiling the engine in modular mode (DLL files on desktop platforms). The opposite is what we call monolithic mode, which puts all code together in a single executable file. The type of build is controlled by UnrealBuildTool settings and/or platforms and build configuration.

The actual API macro equates to one of the following depending on how the code is being compiled by UBT:

  • __declspec( dllexport ), when compiling module code in modular mode.

  • __declspec( dllimport ), when including public module headers for a module that you are importing.

  • empty, when compiling in monolithic mode

API macros only make sense for modules that are statically imported from another module. The Core module is a great example -- almost every other module in UE4 specifies Core as a import dependency in their *.Build.cs file.

Many modules never need to be statically imported (e.g. SceneOutliner module.) We refer to those modules as dynamically loaded modules. Dynamically loaded modules are awesome because they can be discovered at startup (kind of like a plugin), and often can be reloaded on the fly.

The API macros are mostly used on older code to allow newer modules to access it from their DLL. In newer bits of code, the API macros are used far less, instead setting up nice interface layers to expose functionality across DLL boundaries.

关于c++ - SOMTEMPLATE_VR_API 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56788666/

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