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

1 回表示 (過去 30 日間)
Richard Feichtinger
Richard Feichtinger 2019 年 2 月 1 日
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
Richard Feichtinger 2019 年 2 月 4 日
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 2019 年 2 月 4 日
config.m contains a MATLAB function with a configuration select input parameter and (for example) a struct containing all constants as return parameter

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet 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