How to import external c types with namespaces?

25 Ansichten (letzte 30 Tage)
Tobias Pape
Tobias Pape am 22 Jun. 2022
Bearbeitet: Yao Ren am 15 Okt. 2025
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.

Antworten (2)

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

Melden Sie sich an, um zu kommentieren.


Yao Ren
Yao Ren am 9 Mai 2023
Importing struct and enum types inside of C++ namespaces is supported in R2023a. Please upgrade to MATLAB R2023a.
  22 Kommentare
Marcus
Marcus am 10 Okt. 2025
@Yao Ren Ping see above
Yao Ren
Yao Ren am 15 Okt. 2025
Bearbeitet: Yao Ren am 15 Okt. 2025
@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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Representation in Generated Code finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by