Force directory structure on include command in c++

3 vues (au cours des 30 derniers jours)
Paul King
Paul King le 31 Juil 2025
Commenté : Paul King le 5 Août 2025
I have a model in simulink which builds successfully.
The minor issue I have is that the resulting include statement I get in c++ is
#include "trajectory.h"
when I want it to be
#include "interface/trajector.h"
I have tried creating an additional directory in my include folder and then put in #include "interface/trajectory.h" in the Simulation Target. But the resulting code strips out the additional interface directory from the resulting c++ code.
Are there any setting I can use to resolve this ?

Réponses (1)

Alan
Alan le 4 Août 2025
Hello Paul,
From what I understand, you are specifying the include path under “Simulation Targets->Custom Code->Source Files”, but the generated header file is generated outside the specified directory.
Simulink's code generator typically strips directory paths from header file names to maximize portability and avoid hardcoded paths in generated code. Therefore, the include paths could be controlled via the build system (-I flags), not via relative paths in code.
The include directory could be added to a Makefile as follows:
-I/path/to/include/interface
Alternatively, you could use a post-code-generation script to search and move the “trajectory.h” file to the required directory.
Regards,
Alan
  1 commentaire
Paul King
Paul King le 5 Août 2025
Thanks for that I will look into that

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simulink Coder dans Help Center et File Exchange

Tags

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by