How to import external c types with namespaces?

38 次查看(过去 30 天)
I try to import external c header files to my simulink model.
I am using the function ImportExternalCTypes() (Matlab2021b) to import the header file.
Call of the function:
Simulink.importExternalCTypes('test.h', 'Language', 'C++', 'Overwrite', 'on', 'DataDictionary', 'Types.sldd')
Content of the header file test.h:
#include <string>
#include <vector>
#include <stdexcept>
namespace System {
namespace Command {
enum Type {
On,
Off
};
}
enum class Subystem {
Stop,
Start
};
The enumeration within the namespace will be ignored.
Only the enumeration Subystem will be added to the Data Dictionary.
Is there a wag that Matlab recognizes the Enumeration within the namespace?
I get an auto generated header file with the namespaces. All Enumerations are defined within namespaces in the original header file.

回答(2 个)

Nitanshu
Nitanshu 2022-6-28
Hi Tobias,
You can take help from this Matlab documentation.
Hope it helps!
  1 个评论
Tobias Pape
Tobias Pape 2022-7-4
Hi Nitanshu,
thank you for your answer. I already read the documentation.
The documentation does not explain why namespaces will be ignored.

请先登录,再进行评论。


Yao Ren
Yao Ren 2023-5-9
Importing struct and enum types inside of C++ namespaces is supported in R2023a. Please upgrade to MATLAB R2023a.
  9 个评论
Yao Ren
Yao Ren 2024-8-28
编辑:Yao Ren 2024-8-29
Hello @Fe @Marcus, we may be able to support this workflow in R2025a release (roughly 6 months from now). It requires C/C++ types being imported into a Simulink Data Dictionary (SLDD). To use these imported types in a model, model has to link to the SLDD. Is this requirement ok with you? If you have additional requirements, please post them here. Thanks!
Marcus
Marcus 2024-8-29
That works for us. We can support and test this feature in the prerelease if you need any feedback on this new feature.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by