The QM code generation process consists of replacing the code-generation directives in the file templates in the model with the corresponding pieces of auto-generated code in the files generated on disk. All other code fragments surrounding the code-generation directives in the file-templates are simply copied to the files on disk. The picture below illustrates the process:
To work effectively with the code-generation directives in QM, you need to understand the difference between declarations and definitions in C or C++.
A declaration introduces a name and describes its type, be it a type name (struct/class/typedef), object (variable), or a function. A declaration is what the C or C++ compiler needs to accept references to that name. These are declarations:
A definition actually instantiates/implements the symbol. It's what the linker needs in order to link references to those entities. These are definitions corresponding to the above declarations:
The general syntax of the code-generating directives in the QM file templates is:
where $<directive> is one of:
and <model-item> denotes a Fully-Qualified Name of the model item to expand.
The fully-qualified item names can be, of course, typed by hand in the QM file templates. However, to avoid errors, the Model Explorer allows you to drag-n-drop a model item onto a file-template to create a fully-qualified item name, as illustrated in the animation below: