Main Content

Functions to call (-main-generator-calls)

Specify functions that you want the generated main to call after the initialization functions

Description

This option affects a Code Prover analysis only.

This option is not available for code generated from MATLAB® code or Simulink® models.

Specify functions that you want the generated main to call. The main calls these functions after the ones you specify through the option Initialization functions (-functions-called-before-main).

Set Option

User interface (desktop products only): In your project configuration, the option is on the Code Prover Verification node. See Dependencies for other options that you must also enable.

User interface (Polyspace Platform, desktop products only): In your project configuration, the option is on the Static Analysis tab on the Run Time Errors node.

Command line and options file: Use the option -main-generator-calls. See Command-Line Information.

Why Use This Option

If you are verifying a module or library, Code Prover generates a main function if one does not exist. If a main exists, the analysis uses the existing main.

Use this option along with the option Initialization functions (-functions-called-before-main) to specify which functions the generated main must call. Unless a function is called directly or indirectly from main, the software does not analyze the function.

Settings

Default: unused

none

The generated main does not call any function.

unused

The generated main calls only those functions that are not called in the source code. It does not call inlined functions.

all

The generated main calls all functions except inlined ones.

custom

The generated main calls functions that you specify.

Enter function names or choose from a list.

  • Click add field icon to add a field and enter the function name.

  • Click list code function icon to list functions in your code. Choose functions from the list.

If you use the scope resolution operator to specify the function from a particular namespace, enter the fully qualified name, for instance, myClass::myMethod(int). If the function does not have a parameter, use an empty parenthesis, for instance, myClass::myMethod().

Dependencies

This option is available only if you select Verify module or library (-main-generator).

Tips

  • Select unused when you use Code Prover Verification > Verify files independently.

  • If you want the generated main to call an inlined function, select custom and specify the name of the function.

  • To verify a multitasking application without a main, select none.

  • The generated main can call the functions in arbitrary order. If you want to call your functions in a specific order, manually write a main function to call them.

  • To specify instantiations of templates as arguments, run analysis once with the option argument all. Search for the template name in the analysis log and use the template name as it appears in the analysis log for the option argument.

    For instance, to specify this template function instantiation as option argument:

    template <class T>
    T GetMax (T a, T b) {
      T result;
      result = (a>b)? a : b;
      return (result);
    } 
    template int GetMax<int>(int, int); // explicit instantiation
    
    Run an analysis with the option -main-generator-calls all. Search for getMax in the analysis log. You see the function format:
    T1 getMax<int>(T1, T1)
    To call only this template instantiation, remove the space between the arguments and use the option:
    -main-generator-calls custom="T1 getMax<int>(T1,T1)"

Command-Line Information

Parameter: -main-generator-calls
Value: none | unused | all | custom=function1[,function2[,...]]
Default: unused
Example (Code Prover): polyspace-code-prover -sources file_name -main-generator -main-generator-calls all
Example (Code Prover Server): polyspace-code-prover-server -sources file_name -main-generator -main-generator-calls all