Verifica del codice
Dopo la generazione di codice, ispezionare il codice sorgente e i risultati dell'output a scopo di verifica. Il report sulla generazione di codice fornisce un'interfaccia interattiva per ispezionare i file sorgente C/C++ generati, i tipi di dato generati e altre informazioni dettagliate sul codice. Accedere in modo programmatico a un sottoinsieme di informazioni del report sulla generazione di codice utilizzando l'oggetto informativo del report. È possibile verificare l'output del codice MEX generato rispetto al codice MATLAB® originale o creare test personalizzati basati sulle classi di test unitario di MATLAB. È possibile scegliere di generare controlli di errore di runtime che segnalano eventuali errori che si verificano durante l'esecuzione del codice.
Funzioni
codegen | Generate C/C++ code from MATLAB code |
coder.config | Create code generation configuration objects |
coder.ignoreConst | Prevent use of constant value of expression for function specializations |
coder.ignoreSize | Prevent code generator from creating function specializations for constant-size expressions |
coder.mfunctionname | Name of calling function or method (Da R2021b) |
coder.runTest | Run test replacing calls to MATLAB functions with calls to MEX functions |
getLineColumn | Find locations of beginning and end of MATLAB code involved in code generation |
Classi
coder.HardwareImplementation | Hardware-specific configuration parameters for C/C++ code generation from MATLAB code |
Oggetti
coder.CodeConfig | Configuration parameters for C/C++ code generation from MATLAB code |
coder.EmbeddedCodeConfig | Configuration parameters for C/C++ code generation from MATLAB code with Embedded Coder |
coder.MexCodeConfig | Configuration parameters for MEX function generation from MATLAB code |
Proprietà
| coder.BuildLog Properties | Build logs produced during code generation |
| coder.CodeFile Properties | Description of file containing text that is involved in code generation |
| coder.File Properties | Description of file without text that is involved in code generation |
| coder.Function Properties | Description of MATLAB function used in code generation |
| coder.Message Properties | Description of message produced during code generation readiness analysis or during code generation |
| coder.Method Properties | Description of method in a MATLAB class used in code generation |
| coder.ReportInfo Properties | Code generation report information |
| coder.Summary Properties | Summary of code generation from MATLAB code |
Argomenti
Report sulla generazione di codice
- Code Generation Reports
View code generation results. - Tracing Generated C/C++ Code to MATLAB Source Code
Generate traceability tags. - Access Code Generation Report Information Programmatically
Access information about code generation such as input files, generated files, and error messages by using a report information object.
Collaudo del codice generato
- Testing Code Generated from MATLAB Code
Verify numerical behavior of generated code. - Verify MEX Functions in the MATLAB Coder App
Compare results of running the original MATLAB function with the results from running the MEX function. - Verify MEX Functions at the Command Line
Test MEX functions withcoder.runTestor thecodegen-testoption. - Unit Test Generated Code with MATLAB Coder
Run MATLAB unit tests on generated code. - Unit Test External C Code with MATLAB Coder
Run MATLAB unit tests on generated code that integrates external C code.
Rilevamento degli errori di runtime
- Generate Standalone C/C++ Code That Detects and Reports Run-Time Errors
Generate standalone libraries and executables that detect and report run-time errors, such as out-of-bounds array indexing.
Risoluzione dei problemi
- Avoid Duplicate Functions in Generated Code
Reduce the occurrence of duplicate functions in the generated code. - Compiler and Linker Errors
Address common causes of errors that occur during build.

