target.MainFunction 类
命名空间: target
为目标硬件应用程序的 main 函数提供 C 和 C++依赖项
描述
使用 target.MainFunction 类为在目标硬件上运行的应用程序 main 函数提供 main 函数依赖项。例如,C 和 C++ 初始化和终止代码、include 预处理器指令以及应用程序的 main 函数参量规范。
要创建 target.MainFunction 对象,请使用 target.create 函数。
属性
main 依赖项集合的名称。
特性:
GetAccess | public |
SetAccess | public |
main 函数的编译器构建工具依赖项,包括头文件、源文件和库。
特性:
GetAccess | public |
SetAccess | public |
捕获运行时命令行参数参量关系。
特性:
GetAccess | public |
SetAccess | public |
必须使用预处理器指令 #include "path-spec" 将其包含在目标 main 函数中的头文件数组。
特性:
GetAccess | public |
SetAccess | public |
必须使用预处理器指令 #include 将其包含在目标 <path-spec>main 函数中的头文件数组。
特性:
GetAccess | public |
SetAccess | 受保护 |
main 函数用于初始化目标资源的 C 或 C++ 代码的格式化字符串。
特性:
GetAccess | public |
SetAccess | public |
main 函数用来终止目标资源的 C 或 C++ 代码的格式化字符串。
特性:
GetAccess | public |
SetAccess | public |
示例
创建一个 target.MainFunction 对象并将其与 target.Board object 关联,以捕获 Arduino® 板的 main 函数依赖关系。处理器在环 (PIL) 等工作流程可以在为目标硬件上运行的应用程序生成 main 函数时使用此信息。
board = target.create('Board', 'Name', 'Arduino Board') mainFunction = target.create('MainFunction'); mainFunction.Name = 'Arduino Main Dependencies'; mainFunction.IncludeFiles = { 'Arduino.h' }; mainFunction.InitializationCode = fileread('arduino_main_initialization.c'); board.MainFunctions = mainFunction;
在代码片段中,arduino_main_initialization.c 包含 C 代码。例如:
/* Initialize system */
init();
来自 Set Up PIL Connectivity by Using Target Framework 的此代码片段展示了如何创建和使用 target.MainFunction 对象来指定 API 实现所需的 main 函数参量。
comms = target.create('CommunicationInterface'); comms.Name = 'Linux TCP Interface'; comms.Channel = 'TCPChannel'; comms.APIImplementations = target.create('APIImplementation', ... 'Name', 'x86 rtiostream Implementation'); comms.APIImplementations.API = target.create('API', 'Name', 'rtiostream'); comms.APIImplementations.BuildDependencies = target.create('BuildDependencies'); comms.APIImplementations.BuildDependencies.SourceFiles = ... {fullfile('$(MATLABROOT)', ... 'toolbox', ... 'coder', ... 'rtiostream', ... 'src', ... 'rtiostreamtcpip', ... 'rtiostream_tcpip.c')}; comms.APIImplementations.MainFunction = target.create('MainFunction', ... 'Name', 'TCP RtIOStream Main'); comms.APIImplementations.MainFunction.Arguments = {'-blocking', '1', '-port', '0'}; hostTarget.CommunicationInterfaces = comms;
版本历史记录
在 R2020b 中推出
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)