User`s manual
6 Importing and Exporting Data
6-28
Compiling and Linking MAT-File Programs
This section describes the steps required to compile and link MAT-file
programs on UNIX and Windows systems. It begins by looking at a special
consideration for compilers that do not mask floating-point exceptions. Topics
covered are:
•“Masking Floating Point Exceptions”
•“Compiling and Linking on UNIX”
•“Compiling and Linking on Windows”
Masking Floating Point Exceptions
Certain mathematical operations can result in nonfinite values. For example,
division by zero results in the nonfinite IEEE value,
inf. A floating-point
exception occurs when such an operation is performed. Because MATLAB uses
an IEEE model that supports nonfinite values such as
inf and NaN, MATLAB
disables, or masks, floating-point exceptions.
Some compilers do not mask floating-point exceptions by default. This causes
MAT-file applications built with such compilers to terminate when a
floating-point exception occurs. Consequently, you need to take special
precautions when using these compilers to mask floating-point exceptions so
that your MAT-file application will perform properly.
Note MATLAB-based applications should never get floating-point
exceptions. If you do get a floating-point exception, verify that any third party
libraries that you link against do not enable floating-point exception handling.
The only compiler and platform on which you need to mask floating-point
exceptions is the Borland C++ compiler on Windows.
Borland C++ Compiler on Windows
To mask floating-point exceptions when using the Borland C++ compiler on
the Windows platform, you must add some code to your program. Include the
following at the beginning of your
main() or WinMain() function, before any
calls to MATLAB API functions.