C Mex MATLAB Version

版本 4.1.0.0 (12.4 KB) 作者: James Tursa
Mex C code to determine MATLAB version at compile time and run time
679.0 次下载
更新时间 2019/5/20

查看许可证

This submission provides the following files to assist the programmer in creating robust C/C++ mex code that can compile and run under multiple MATLAB versions:
(1) matlab_version.h provides pre-processor code that defines the macro MATLAB_VERSION, which will contain the hex number equivalent of the MATLAB version that is being used for the compile (e.g., a value of 0x2015b would indicate MATLAB version R2015b). It also defines the macro TARGET_API_VERSION to differentiate between the R2017b and R2018a API libraries being used. And it contains a prototype for the matlab_version() function that is contained in the matlab_version.c file.

(2) matlab_version.c provides code for the matlab_version() function, which returns the hex number equivalent of the MATLAB version that is currently being run. (via a mexCallMATLAB callback)

(3) matlab_version_test.c provides code for a mex routine that tests matlab_version.h and matlab_version.c

(4) matlab_version_test.m provides m-code that will automatically compile the matlab_version_test.c file.

To test all of this, simply type at the command line:

>> matlab_version_test

There are also extensive comments at the front end of the matlab_version.h file that describe an assortment of mxArray and API changes over the years. The idea is that the macro MATLAB_VERSION can be used to determine whether various library functions or features that the programmer is depending on are actually available in the version being used for the compile. E.g., the programmer could use an #if - #else - #endif block to conditionally compile different code depending on the value of MATLAB_VERSION. And the matlab_version( ) function result can be used to determine if a MATLAB function the programmer wants to call with mexCallMATLAB is actually available in the current version of MATLAB being run.

Tested under various Win32 and Win64 versions of MATLAB from R2009a - R2018a.

引用格式

James Tursa (2024). C Mex MATLAB Version (https://www.mathworks.com/matlabcentral/fileexchange/67016-c-mex-matlab-version), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2017b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息
标签 添加标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
4.1.0.0

Updated notes for R2019a mxArray CrossLink field move.

4.0.0.0

Updated notes for mxArrayToString and mxArrayToUTF8String API functions.

3.0.0.0

Updated the comments for R2018a, and split the matlab_version() code and the mex test code into two separate files.

2.0.0.0