matlab.engine.typedinterface.generateCPP
Generate C++ code interface for MATLAB packages, classes, and functions
Description
matlab.engine.typedinterface.generateCPP(
creates a C++ headerFile
,Name=Value
)headerFile
from one or more MATLAB® packages, classes, and functions. You must specify at least one
Packages
, Classes
, or Functions
name-value argument. Use the headerFile
to build a C++ engine
application. For more information, see Write MATLAB Code for Strongly Typed Interface.
Examples
Create Header File from MATLAB Package
Create a C++ header file myPkg.hpp
from
MATLAB classes Position
and Rectangle
in a
shapes
package.
Create a package named shapes
on the MATLAB path.
Create a package file Position.m
with these statements.
classdef Position properties X (1,1) double {mustBeReal} Y (1,1) double {mustBeReal} end end
Create a package file Rectangle.m
with these statements.
classdef Rectangle properties UpperLeft (1,1) shapes.Position LowerRight (1,1) shapes.Position end methods function R = enlarge(R, n) arguments R (1,1) shapes.Rectangle n (1,1) double {mustBeReal} end % code end function R = show(R) arguments R (1,1) shapes.Rectangle end % code disp("Upper left position (" + R.UpperLeft.X + "," + R.UpperLeft.Y + ")"); disp("Lower right position (" + R.LowerRight.X + "," + R.LowerRight.Y + ")"); end end end
Generate the C++ interface header file myPkg.hpp
.
matlab.engine.typedinterface.generateCPP("myPkg.hpp",Packages="shapes")
2 class(es) and 0 function(s) written to myPkg.hpp
Use header file myPkg.hpp
to build a C++ engine
application.
Input Arguments
headerFile
— C++ header file
string scalar | character vector
C++ header file created by the function, specified as a string or a character vector.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: Classes=["Position","Rectangle"],DisplayReport=true,SaveReport="report.log"
Note
You must specify at least one Packages
, Classes
,
or Functions
name-value argument.
Packages
— MATLAB packages
string array
MATLAB packages to include in the C++ code interface, specified as a string array.
Example: Packages="shapes"
Classes
— MATLAB classes
string array
MATLAB classes to include in the C++ code interface, specified as a string array. The function supports user-authored classes and classes inherited from other user-authored classes.
Example: Classes=["Position","Rectangle"]
Functions
— MATLAB functions
string array
MATLAB functions to include in the C++ code interface, specified as a string array. The function supports user-authored functions.
Example: Functions=["show","enlarge"]
DisplayReport
— Option to display generation messages
false
or 0
(default) | true
or 1
Option to display generation messages, specified as a numeric or logical
1
(true
) or 0
(false
).
SaveReport
— Log file name
string scalar
Log file name, specified as a string scalar. The name can include a relative or
absolute path. The option creates a text file, so you can specify an appropriate file
extension, but that is not required. The file contains detailed information about the
matlab.engine.typedinterface.generateCPP
function call and the
generated structures.
Example: SaveReport="report.log"
Version History
See Also
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)