How to import external c types with namespaces?

조회 수: 57 (최근 30일)
Tobias Pape
Tobias Pape 2022년 6월 22일
편집: Yao Ren 2025년 10월 15일 16:48
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.
  댓글 수: 22
Marcus
Marcus 2025년 10월 10일 8:39
@Yao Ren Ping see above
Yao Ren
Yao Ren 2025년 10월 15일 16:47
편집: Yao Ren 2025년 10월 15일 16:48
@Marcus Please contact MathWorks support to open a case. We can go from there, for example a Webex or MSTeams meeting to disucss the requirements.

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

카테고리

Help CenterFile Exchange에서 Data Representation in Generated Code에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by