Using C++ with DSP/BIOS
Program Generation
2-29
Example 2-4.
Declaring Functions in an Extern C Block
This allows you to refer to the functions within the configuration. For example,
if you had an SWI object which should run function1() every time that the SWI
posts, you would use function1 for the function property of that SWI object.
Functions declared within the extern C block are not subject to name
mangling. Since function overloading is accomplished through name
mangling, function overloading has limitations for functions that are called
from the configuration. Only one version of an overloaded function can
appear within the extern C block. The code in Example 2-5 would result in an
error.
Example 2-5.
Function Overloading Limitation
While you can use name overloading in your DSP/BIOS C++ applications,
only one version of the overloaded function can be called from the
configuration.
Default parameters is a C++ feature that is not available for functions called
from the configuration. C++ allows you to specify default values for formal
parameters within the function declaration. However, a function called from
the configuration must provide parameter values. If no values are specified,
the actual parameter values are undefined.
2.9.3
Calling Class Methods from the Configuration
Often, the function that you want to reference within the configuration is the
member function of a class object. It is not possible to call these member
functions directly from the configuration, but it is possible to accomplish the
same action through wrapper functions. By writing a wrapper function which
accepts a class instance as a parameter, you can invoke the class member
function from within the wrapper.
A wrapper function for a class method is shown in Example 2-6.
extern "C" {
Void function1();
Int function2();
}
extern “C” {
Int addNums(Int x, Int y);
Int addNums(Int x, Int y, Int z); // error, only one version
// of addNums is allowed
}
Содержание TMS320 Series
Страница 1: ...TMS320 DSP BIOS v5 40 User s Guide Literature Number SPRU423G April 2009 ...
Страница 16: ...xvi ...
Страница 152: ...Tasks 4 48 Figure 4 12 Trace from Example 4 7 ...
Страница 168: ...Semaphores 4 64 Figure 4 14 Trace Results from Example 4 11 ...
Страница 202: ...5 20 ...
Страница 287: ...Index 9 Index Void 1 11 W words data memory 3 15 of code 1 5 wrapper function 2 29 ...
Страница 288: ...Index 10 Index ...