メインコンテンツ

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

getPreincludeFiles

Get preinclude files from build information

R2024a 以降

説明

files = getPreincludeFiles(buildinfo,concatenatePaths,replaceMatlabroot,includeGroups,excludeGroups) returns names of preinclude files that are described in the build information.

すべて折りたたむ

This example shows how to get preinclude file names from a build information object.

Suppose you have two files, myFile.c and myInc.h, in your current working folder.

// myFile.c
#include <stdio.h>
int main(void) {
    #ifdef __STDC_VERSION__
    printf("__STDC_VERSION__ is defined\n");
    #else
    printf("__STDC_VERSION__ is not defined\n");
    #endif
 
    #ifdef MY_MACRO
    printf("MY_MACRO is defined\n");
    #else
    printf("MY_MACRO is not defined\n");
    #endif
}


// myInc.h
#ifndef MYINC_H
#define MYINC_H
 
#define MY_MACRO
 
#endif

Create an RTW.BuildInfo object and specify source files, undefine directives, and preinclude files.

buildInfo = RTW.BuildInfo;
buildInfo.ComponentName = 'MyComponent';
addSourceFiles(buildInfo, 'myfile.c');
addUndefines(buildInfo, '__STDC_VERSION__');
addPreincludeFiles(buildInfo, 'myinc.h');

Get the preinclude filenames.

preincFiles=getPreincludeFiles(buildInfo,true,false)
preincFiles =

  1×1 cell array

    {'myinc.h'}

入力引数

すべて折りたたむ

Required. RTW.BuildInfo object that contains information for compiling and linking generated code.

Required. Specify whether to concatenate paths and filenames that the function returns:

  • true –– Return list of full paths to preinclude files.

  • false –– Return only filenames of preinclude files.

Required. Specify whether to replace the $(MATLAB_ROOT) and $(START_DIR) tokens:

  • true –– Replace $(MATLAB_ROOT) and $(START_DIR) with the MATLAB® installation folder and the code generation folder respectively.

  • false –– Do not replace $(MATLAB_ROOT) and $(START_DIR).

Optional. Specify the file groups that you want to include in the query. To view the group name of a file group, access the Group property of the corresponding object.

Optional. Specify the file groups that you want to exclude from the query. To view the group name of a file group, access the Group property of the corresponding object.

Output Arguments

すべて折りたたむ

Names of preinclude files that the function obtains from the build information.

バージョン履歴

R2024a で導入