Texas Instruments TMS320 User Manual page 59

Dsp/bios v5.40
Hide thumbs Also See for TMS320:
Table of Contents

Advertisement

Example 2-4. Declaring Functions in an Extern C Block
Example 2-5. Function Overloading Limitation
2.9.3
Calling Class Methods from the Configuration
extern "C" {
Void function1();
Int function2();
}
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.
extern "C" {
Int addNums(Int x, Int y);
Int addNums(Int x, Int y, Int z); // error, only one version
}
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.
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.
Using C++ with DSP/BIOS
// of addNums is allowed
Program Generation
2-29

Advertisement

Table of Contents
loading

Table of Contents