외부 코드 통합
C/C++에서 개발된 외부 코드, 사용자 지정 코드 또는 레거시 코드가 있는 경우 이 코드를 MATLAB 코드에 직접 통합할 수 있습니다. 예를 들면 다음과 같습니다.
C/C++ 함수를 호출하려면
coder.ceval함수를 사용하십시오. 코드 생성기는 C/C++ 코드를 MATLAB에서 생성된 C/C++ 코드에 통합합니다. 생성 코드와 함께 사용하려는, C/C++에서 개발된 외부 라이브러리, 최적화된 코드 또는 오브젝트 파일이 있는 경우 코드를 통합하십시오.데이터형(예:포인터 유형 또는 외부 파일 I/O용
FILE유형)을 MATLAB 코드에서 정의할 수 없는 외부 코드에 전달하거나 외부 코드로부터 이를 전달받으려면coder.opaque함수를 사용하십시오.외부 소스 파일, 헤더 파일, 오브젝트 파일 및 라이브러리를 포함하고 링크하도록 빌드를 구성하려면
coder.updateBuildInfo를 사용하십시오.외부 C 라이브러리에 객체 지향 인터페이스를 제공하려면 함수 호출을
coder.ExternalDependency슈퍼클래스에서 파생된 클래스로 패키징하십시오.생성 코드와 통합할 사용자 지정 C/C++ 코드에서 사용하기 위해 특정 식별자 이름을 예약하려면
coder.reservedName함수를 사용하십시오.외부 구조체 유형과 상호 작용하려면
coder.cstructname함수를 사용하십시오.
클래스
coder.ExternalDependency | Interface to external code |
coder.BuildConfig | Build context during code generation |
함수
coder.ceval | 생성 코드에서 C/C++ 함수 호출 |
coder.ref | Indicate data to pass by reference |
coder.rref | Indicate read-only data to pass by reference |
coder.wref | Indicate write-only data to pass by reference |
coder.cinclude | Include header file in generated code |
coder.opaque | Declare variable in generated code |
coder.reservedName | Generate code that does not use specified identifier names |
coder.updateBuildInfo | Update RTW.BuildInfo build information object |
도움말 항목
- Configure Build for External C/C++ Code
Specify source files and build parameters for external C/C++ code.
- Integrate External Code That Uses Pointers, Structures, and Arrays
Integrate external C code that uses pointers, structures, and arrays into MATLAB code.
- Pass by Reference to and from External C Functions
Pass data by reference to and from an external C function.
- Integrate External Code That Uses Custom Data Types
Use C types that are not native to MATLAB in an external function.
- Develop Interface for External C/C++ Code
Access your external code using a class interface.
- Mapping MATLAB Types to Types in Generated Code
Understand how the code generator maps MATLAB data types to data types in the generated C/C++ code.
- Integrate Multiple Generated C++ Code Projects
Integrate the generated C++ code from two projects into a single larger project.
문제 해결
Resolve Error: Unknown Output Type for coder.ceval
Troubleshoot error when the code generator is unable to determine the output type of an external C/C++ function call.
