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

2 次查看(过去 30 天)
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?

回答(1 个)

Anakin Zheng
Anakin Zheng 2019-2-1
There is no such feature at this point.
Is there any reason you want everything in one header?
Thanks
  2 个评论
Richard Feichtinger
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
config.m contains a MATLAB function with a configuration select input parameter and (for example) a struct containing all constants as return parameter

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB Coder 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by