이 페이지는 기계 번역을 사용하여 번역되었습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.
C 코드 구문를 위한 모델링 패턴
특정 C 구문을 생성하는 모델링 패턴 적용
생성된 코드에서 특정 C 구문을 생성하기 위한 모델을 설정하는 데에는 여러 가지 표준 방법을 사용할 수 있습니다. 블록, S-Function, Stateflow 차트, MATLAB 함수 블록, 데이터 객체 및 사용자 지정 스토리지 클래스를 사용하면 데이터형, 구조체, 배열, 제어 흐름 구조, 함수, 전처리기 지시문 및 포인터와 같은 C 구문을 생성할 수 있습니다. 시작하려면 Prepare a Model for Code Generation 항목을 참조하십시오. 표준, 지침 및 블록 사용 항목도 참조하십시오.
도움말 항목
유형, 연산자 및 표현식
- Typedef
Create data type aliases by generatingtypedef
statements. - Definition, Initialization, and Declaration of Parameter Data
Control the file placement of the declaration, definition, and initialization of parameter data. - Definition and Declaration of Signal Data
Control the file placement of the declaration and definition of signal data. - Data Type Conversion
Create a data type conversion using a Data Type Conversion block, Stateflow Chart, or MATLAB Function block. - Type Qualifiers
Apply theconst
andvolatile
keywords to a global variable that represents parameter data. - Relational and Logical Operators
Implement relational and logical operators using Simulink blocks, Stateflow Charts, and MATLAB Function blocks. - Bitwise Operations
Perform bitwise operations using the Bitwise Operator block, a Stateflow Chart, or MATLAB Function block. - Enumeration
To generate an enumerated data type, define an enumeration class in a MATLAB file.
제어 흐름
- If-Else
Use a Switch block, a Stateflow Chart, or MATLAB Function block to create anif-else
statement in the generated code. - Switch
Use a Switch Case block or MATLAB Function block to create answitch
statement in the generated code. - For Loop
Use a For-Iterator Subsystem block, Stateflow Chart, or MATLAB Function block to create afor
loop in the generated code. - While Loop
Use a White Iterator Subsystem block, Stateflow Chart, or MATLAB Function block to create awhile
loop in the generated code. - Do While Loop
Use a While Iterator Subsystem block or Stateflow Chart to create ado while
loop in the generated code.
함수
- Function Call
To generate a function call, add a subsystem, which implements the operations that you want. - Function Prototyping
Create a function call using graphical functions or function prototype control. - External C Functions
Integrate legacy C functions in the generated code by either creating an S-function or making a call to an external C function.
전처리기 지시문
- Macro Definitions (#define)
Generate parameter data as a constant-valued macro. - Conditional Inclusions (#if / #endif)
Include preprocessor conditionals in your generated code by implementing variant blocks in your model.
구조체
- Structures of Parameters
Create a flat structure or nested structures that store parameter data in the generated code. - Structures of Signals
Create a flat structure that contains signal data in the generated code. - Nested Structures of Signals
Create a structure whose fields are also structures. - Bitfields
Store Boolean data in bitfields in the generated code.
배열
- Arrays for Parameters
Create an array of parameter data in the generated code. - Arrays for Signals
Create an array of signal data in the generated code.
포인터
- Pointers
Generate code that accesses data from your handwritten code through a pointer.