The build worked fine. When i try to generate the code from simulink model, I'm prompted with this error.
Matlab version : 2020a

댓글 수: 1

I'd contact MATLAB support:
If you want to try some suggestions from AI first, here is the answer I got:
The error Undefined function 'PrePragma' for input argument of type 'handle.handle' during Simulink code generation typically occurs when your model references legacy Custom Storage Classes (CSCs), memory sections, or an older third-party target (such as AUTOSAR or specific microcontroller packages).
In MATLAB, PrePragma
is a property of memory section definition objects. This error means a script (like a build hook or TLC file) is trying to call it as a standalone function (PrePragma(handle)) rather than accessing it as a property, or the underlying data package is hitting a compatibility wall with R2020a's data dictionary framework.
Here is how you can resolve the issue:
1. Update and Save Your Custom Storage Classes (CSCs)
If you are using a custom data package created in an older MATLAB version, the internal class definitions might be incompatible with R2020a's Embedded Coder Dictionary.
  • Open the Custom Storage Class Designer in the MATLAB Command Window:
matlab
cscdesigner
  • Select your custom package, navigate through its memory sections, and resave/validate the package to migrate the underlying data structures to R2020a format.
2. Search for Syntax Errors in Build Hooks
If you are using user-defined pre/post-build hooks or TLC files, look for any occurrences of PrePragma.
  • Incorrect syntax (triggers this error): PrePragma(h)
  • Correct syntax: h.PrePragma or get(h, 'PrePragma')
3. Clear the MATLAB Path and Toolbox Cache
Shadowed paths from older MATLAB installations frequently cause handle object errors. Reset your path and rebuild the cache with these commands:
matlab
restoredefaultpath;
rehash toolboxcache;
savepath;
Make sure to restart MATLAB after running these commands.
4. Check Your System Target File (STF)
If your model relies on a proprietary or older hardware target:
  1. Open the model Configuration Parameters (Ctrl + E).
  2. Go to the Code Generation tab.
  3. Check the selected System target file (e.g., ert.tlc, grt.tlc, or a custom vendor file). Switch it temporarily to a standard target like ert.tlc (Embedded Coder) to verify if a custom target is the root cause.
5. Wipe Local Build Artifacts
Corrupted cache files from previous successful runs or older MATLAB versions can cause sudden generation failures.
  • Delete the slprj folder and your model's build folder (e.g., your_model_ert_rtw) from your current directory, then try generating the code again.

댓글을 달려면 로그인하십시오.

답변 (0개)

제품

릴리스

R2020a

태그

질문:

대략 12시간 전

댓글:

대략 8시간 전

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by