Main Content

getPreincludeFiles

Get preinclude files from build information

Since R2024a

Description

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

example

Examples

collapse all

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'}

Input Arguments

collapse all

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

collapse all

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

Version History

Introduced in R2024a