MATLAB Compiler    

Compiling Private and Method Functions

Private functions are functions that reside in subdirectories with the special name private, and are visible only to functions in the parent directory. Since private functions are invisible outside of the parent directory, they can use the same names as functions in other directories. Because MATLAB looks for private functions before standard M-file functions, it will find a private function before a nonprivate one.

Method functions are implementations specific to a particular MATLAB type or user-defined object. Method functions are only invoked when the argument list contains an object of the correct class.

In order to compile a method function, you must specify the name of the method along with the classname so that the Compiler can differentiate the method function from a nonmethod (normal) function.

Method directories can contain private directories. Private functions are found only when executing a method from the parent method directory. Taking all of this into account, the Compiler command line needs to be able to differentiate between these various functions that have the same name. A file called foo.m that contains a function called foo can appear in all of these locations at the same time. The conventions used on the Compiler command line are documented in this table.

Name
Description
foo.m
Default version of foo.m
xxx/private/foo.m
foo.m private to the xxx directory
@cell/foo.m
foo.m method to operate on cell arrays
@cell/private/foo.m
foo.m private to methods that operate on cell arrays

This table lists the functions you can specify on the command line and their corresponding function and filenames.

Function
C Function
C++ Function
Filename
foo
mlfFoo
mlxFoo
mlNFoo
mlfNFoo
mlfVFoo

foo
Nfoo
Vfoo
mlxFoo

foo.c
foo.h
foo.cpp
foo.hpp

@cell/foo
mlf_cell_foo
mlx_cell_foo
mlN_cell_foo
mlfN_cell_foo
mlfV_cell_foo

_cell_foo
N_cell_foo
V_cell_foo
mlx_cell_foo

_cell_foo.c
_cell_foo.h
_cell_foo.cpp
_cell_foo.hpp

xxx/private/foo
mlfXXX_private_foo
mlxXXX_private_foo
mlNXXX_private_foo
mlfNXXX_private_foo
mlfVXXX_private_foo

XXX_private_foo
NXXX_private_foo
VXXX_private_foo
mlxXXX_private_foo

_XXX_private_foo.c
_XXX_private_foo.h
_XXX_private_foo.cpp
_XXX_private_foo.hpp

@cell/private/foo
mlfcell_private_foo
mlxcell_private_Foo
mlNcell_private_Foo
mlfNcell_private_Foo
mlfVcell_private_Foo

_cell_private_foo
N_cell_private_foo
V_cell_private_foo
mlx_cell_private_foo

_cell_private_foo.c
_cell_private_foo.h
_cell_private_foo.cpp
_cell_private_foo.hpp

For private functions, the name given in the table above may be ambiguous. The MATLAB Compiler generates a warning when it cannot distinguish which private function to use. For example, given these two foo.m private functions and their locations

the Compiler searches up only one level and determines the path to the file as

Since it is ambiguous which foo.m you are requesting, it generates the warning


  Generated Code The Generated Header Files