%#mex编译指示做什么? [英] What does the %#mex pragma do?

查看:100
本文介绍了%#mex编译指示做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在MATLAB中创建MEX文件时,我习惯于也创建一个具有相同名称的.m文件,一个与MEX文件相同的功能签名,否则仅包含以下形式的帮助文本:的注释,然后在键入help myfcn时显示.

When I create a MEX file in MATLAB, I'm in the habit of also creating a .m file with the same name, a function signature identical to the MEX file, and otherwise containing nothing but help text in the form of comments, that are then displayed when one types help myfcn.

这样做的时候,一个小的副作用是MATLAB Code Analyzer注意到函数签名中指定的输入和输出参数未被使用,并用橙色下划线标记它们.

When one does this, a small side-effect is that MATLAB Code Analyzer picks up on the fact that the input and output arguments specified in the function signature are unused, and flags them with an orange underline.

最近,我发现几个MathWorks内部函数遵循类似于此模式的内容,但是还包括以下几行,与主要帮助文本之间用空行分隔:

Recently I've discovered that several MathWorks internal functions follow something similar to this pattern, but also including the following line, separated by a blank line from the main help text:

%#mex

%#mex杂注似乎没有记录(至少我找不到对此的任何引用). 它似乎直接用来指示.m文件仅旨在为MEX文件提供帮助文本.它具有抑制文件中任何代码分析器消息的作用.

This %#mex pragma appears to be undocumented (at least I can't find any reference to it). It would appear to be used to directly indicate that a .m file is intended only to provide help text for a MEX file. It has the effect of suppressing any Code Analyzer messages in the file.

有人熟悉%#mex编译指示的预期用途吗?除抑制代码分析器消息外,它还有其他作用吗?

Is anyone familiar with the intended use of the %#mex pragma? Does it have any other effects other suppressing Code Analyzer messages?

示例:

\toolbox\compiler\mcc.m
\toolbox\images\images\private\ddist.m
\toolbox\matlab\audiovideo\private\readavi.m
\toolbox\matlab\imagesci\hdf.m
\toolbox\matlab\sparfun\arpackc.m
\toolbox\matlab\specgraph\private\ditherc.m

推荐答案

显然,这是旧版本中记录的.这是存档文档中的页面一直回溯到3.0版的MATLAB编译器(大约在MATLAB 6.5 R13中):

Apparently this was documented in older releases. Here is a page from the archived documentation going all the way back to version 3.0 of the MATLAB Compiler (circa MATLAB 6.5 R13):

%#mex

此编译指示通知MATLAB编译器在 现有的M文件.

This pragma informs the MATLAB Compiler to select the MEX-file over an existing M-file.

如果使用%#function编译指示来定义以下功能 在M代码中不可用,您应该使用%#external编译指示 定义功能.例如:

If you are using the %#function pragma to define functions that are not available in M-code, you should use the %#external pragma to define the function. For example:

function y = gamma(x)
    %#mex
    error('gamma MEX-file is missing');

这是另一个相关的页面,解释何时使用此编译指示:

Here is another related page that explains when this pragma is used:

现在可以从编译器生成的文件中调用MEX文件 独立应用程序.编译器将在任何时候编译MEX文件 它们是在命令行上指定的,或者是使用-h定位的 查找助手功能的选项.然后将加载MEX文件并 由独立代码调用.

It is now possible to call MEX-files from Compiler-generated stand-alone applications. The Compiler will compile MEX-files whenever they are specified on the command line or are located using the -h option to find helper functions. The MEX-files will then be loaded and called by the stand-alone code.

如果M文件和MEX文件出现在同一目录中,并且 M文件包含至少一个函数,编译器将编译 M文件而不是MEX文件.如果需要MEX文件, 您必须使用%#mex编译指示.有关此实用程序的更多信息, 请参阅%#mex参考页.

If an M-file and a MEX-file appear in the same directory and the M-file contains at least one function, the Compiler will compile the M-file instead of the MEX-file. If the MEX-file is desired instead, you must use the %#mex pragma. For more information on this pragma, see the %#mex reference page.

当然,MATLAB编译器是当时的完全不同的产品,能够生成独立的C/C ++程序和MEX文件(没有像今天的版本那样具有MCR依赖性)

of course the MATLAB Compiler was a completely different product back then, capable of producing standalone C/C++ programs and MEX-files (no MCR dependency like today's version)

mlint似乎仍然可以识别这种杂用,并完全将M文件排除在分析之外.

It seems that mlint still recognizes this pragma and completely excludes the M-file from analysis.

这篇关于%#mex编译指示做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆