MATLAB coder settings for generating code for external project c/c++

1 visualización (últimos 30 días)
Depending on the settings, applying MATLAB coder on a filename.m generates as a minimum these files:
  • filename.h, filename.c, filename_types.h, rtwtypes.h, filename_initialize.h, filename_initialize.c
Is there any option the get to content of filename.h & filename.c coded in a filename.h file only?
  • In filename.h there are the includes #include <stddef.h> and #include <stdlib.h>
Is it possible (by any settings) to get rid of this auto-includes?

Respuestas (1)

Anakin Zheng
Anakin Zheng el 1 de Feb. de 2019
There is no such feature at this point.
Is there any reason you want everything in one header?
Thanks
  2 comentarios
Richard Feichtinger
Richard Feichtinger el 4 de Feb. de 2019
The usecase, with the idea to set up an automated flow, is:
  • test_main.m calls a main.m and a functinonal equal mex-wrapper/main.cc
  • config.m just includes constants for different configurations -> used by main.m
  • config.m -> MATLAB coder called from test_main.m -> C/C++ file containing these constants -> used by main.cc
  • mex-file is compiled with "C/C++ file containing these constants" on the fly
  • when "cosim" passed -> main.cc is used in another C++ environment
  • issue 1: include files stdlib.h, stddef.h crashes in other C++ environment
  • issue 2: compile errors occur when compiling/linking config.c/config.h while including a config.h containing the constant declarations works perfect
Issue 2 might be solved by further investigations but just binding some constants into a C/C++ file it's an overhead and moreover it's confusing if at least 6 files (see above) have to be included.
Besides this approach if there is any other convenient way to pass the constants with the required C++ type defs on the fly into the C++ world I would like to use it. Any suggestions?
Richard Feichtinger
Richard Feichtinger el 4 de Feb. de 2019
config.m contains a MATLAB function with a configuration select input parameter and (for example) a struct containing all constants as return parameter

Iniciar sesión para comentar.

Categorías

Más información sobre Get Started with MATLAB Coder en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by