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
다운로드 수: 662
업데이트 날짜: 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