Main Content

getUndefines

From build information, get preprocessor macros to undefine

Since R2024a

Description

example

undefines = getUndefines(buildinfo,includeGroups,excludeGroups) gets, from the build information, preprocessor macros to undefine.

Examples

collapse all

This example shows how to get, from a build information object, preprocessor macros to undefine.

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 preprocessor macros to undefine.

undefines=getUndefines(buildInfo)
undefines =

  1×1 cell array

    {'__STDC_VERSION__'}

Input Arguments

collapse all

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

Optional. Specify the undefine preprocessor macro groups that you want to include in the query. To see what groups exist, run myGroups = getGroups(buildInfo). If you specify "" (empty), the function queries all file groups.

Optional. Specify the undefine preprocessor macro groups that you want to exclude from the query. To see what groups exist, run myGroups = getGroups(buildInfo). If you specify "" (empty), the function queries all file groups.

Output Arguments

collapse all

Preprocessor macros to undefine, which the function obtains from the build information.

Version History

Introduced in R2024a