Hello everybody,
the DMC Library makes extensive use of macro expansions. It works fine and I use this programming technique for my custom software modules as well. But there are two things i just couldn't figure out and I hope someone of you can tell me:
1. What is the purpose of the "User defined Data type of pointer to the module"? e.g. in svgen_dq module:
At first the clumsy expression with the struct gets replaced by the symbol SVGENDQ. A new datatype is born. With this new datatype one can define variables e.g. svgen_dq1. So far so good, but then the Symbol SVGENDQ gets replaced by a pointer:
typedef SVGENDQ *SVGENDQ_handle;
As far as i know this pointer is never used, neither in the documention of the softwaremodule nor in any of the code examples. What is its purpose?
2. Why a macro extension can be smaller and faster than an inline function, and what are the certain circumstances for further optimization of the macro expansion mentioned below?
From the http://focus.ti.com/lit/an/spraak2/spraak2.pdf :
To inline the function, the code is placed in the client file itself, and is qualified with the inline keyword,
as shown in Example 6.
Another optimization is sometimes possible; that is, to turn the function into a macro expansion. This
allows the compiler to optimize further under certain circumstances and produces less code, and
consumes fewer cycles to execute. Such a version of the PID controller was tested, and the results are
documented in Step 8, in Table 1. The code for such a version of the PID controller is shown in
Example 7.
Thanks for any help and greetings from Germany
Thomas