Below are example snippets of the second method of the TestStand sequence and code snippet in the DLL:
1. The step to retrieve the reference to the callback function (pointer points to a function):

2. The step to call the target function with callback:

3. The code snippet in the source code of the DLL:
#include <limits.h>
#include "MathLibrary.h"
// My add function.
void add_numbers(int a, int b, int* sum) {
*sum = a + b;
}
// My minus function.
void minus_numbers(int a, int b, int* difference) {
*difference = a - b;
}
void* get_function(const int selection) {
void (*add_func_ptr)(int, int, int*);
add_func_ptr = &add_numbers;
void (*minus_func_ptr)(int, int, int*);
minus_func_ptr = &minus_numbers;
if (selection == 1)
return add_func_ptr;
else
return minus_func_ptr;
}
typedef void (*FunctionPtr)(int, int, int*);
// My target function.
void targeted_func(FunctionPtr callback, int a, int b, int* result) {
(callback)(a,b,result);
}