How can I declare pointer types on 32-bit and 64-bit platforms without changing the code in a Fortran MEX-file in MATLAB 7.1 (R14SP3)?
2 次查看(过去 30 天)
显示 更早的评论
I am trying to execute my Fortran MEX-file on a 64-bit Linux machine using MATLAB 7.1 (R14SP3). I previously successfully compiled the file on a 32-bit Linux machine. My file uses the INTEGER datatype.
Now that I am moving to a 64-bit machine, I will need to use the INTEGER*8 datatype. Rather than replacing all occurrences of INTEGER with INTEGER*8, I want to know whether there is a way to write architecture-independent code that will use the correct INTEGER datatype depending on what architecture the MEX-file is executed on.
采纳的回答
MathWorks Support Team
2009-6-27
This enhancement has been incorporated in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
If your Fortran compiler supports preprocessing, use the MWPOINTER macro instead of INTEGER to declare mxArrays and other MATLAB pointer types. The Fortran preprocessor converts MWPOINTER to INTEGER*4 on 32-bit platforms and INTEGER*8 on 64-bit platforms.
To use MWPOINTER, you must include the following line in your Fortran source file:
#include "fintrf.h"
For examples of use of MWPOINTER, open any of the files with the extension .F in the directory $MATLAB\extern\examples (where $MATLAB is the MATLAB root directory on your machine, as returned by typing
matlabroot
at the MATLAB command prompt.)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!