Skip to content

void sample_function(int input1)

CountrySideEngineer edited this page Nov 10, 2022 · 1 revision

void sample_function(int input1)

This page describes the stub code for function void sample_function(int input1), a method which has an argument.

stub source file

The stub codes in source file is like below:

long sample_function_called_count;
int sample_function_input1[STUB_BUFFER_SIZE_1];

void sample_function_init()
{
    sample_function_called_count = 0;
    for (int index = 0; index < STUB_BUFFER_SIZE_1; index++) {
        sample_function_input1[index] = 0;
    }
}

void sample_function(int input1)
{
    sample_function_input1[sample_function_called_count] = input1;

    sample_function_called_count++;
}

The variable sample_function_input1[STUB_BUFFER_SIZE_1] is a buffer to store the argument value.
The naming rule for variable that hold values passed as arguments is as follows:
(function_name)_(argument_name)
Prepare for a function to be called more than once, the variable is declared as an array.
The macro to show the size of the array is defined in its header file.

header file

The stub code in header file is like below:

extern long sample_function_called_count;
extern int sample_function_input1[];

void sample_function_init();