Code generated : error C2027: use of undefined type 'Block'
4 次查看(过去 30 天)
显示 更早的评论
Good afternoon.
I was attempting to create an executable from my model using Embedded Coder. However, when building the code for certain blocks within a subsystem, I encountered an error related to the usage of an undefined type.
The "undefined type" for these blocks is defined in a specific .h file. Both the .cpp and .h files are generated according to the .tlc file.
I am not an expert in code generation. The blocks experiencing this issue are generated using C++ code and a tool employed by my company for converting C++ to MATLAB.
For each problematic blocks, the content of the build folder included header files and dependencies:

So the undefined block is actually decleared and defined, in the .h file associated to it.
Do I need to set some additional option for the building?
1 个评论
Pratyush Swain
2025-3-28
Hi Antimo,
From your description it seems you have external dependencies, that you want to add for code generation.Currently your external definition is available in .h file. I would recommend to leverage Model Configuration Parameters for code generation custom code: https://www.mathworks.com/help/rtw/ref/code-generation-pane-custom-code.html
If you are using C++ based S functions in your model, you can also refer to https://www.mathworks.com/help/rtw/code-generation-for-custom-blocks.html
Hope this helps.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!