/vmb, /vmg (Representation Method)
| Overview | How Do I | Compiler Options
These options select the method that the compiler uses to represent pointers to class members. You can also use #pragma pointers_to_members in your code to specify a pointer representation.
Command Line | Project Settings | Description |
/vmb | Best-Case Always | Use this option if you always define a class before you declare a pointer to a member of the class. |
/vmg | General-Purpose Always | Use this option if you need to declare a pointer to a member of a class before defining the class. This need can arise if you define members in two different classes that reference each other. For such mutually referencing classes, one class must be referenced before it is defined. You must then choose an inheritance model from the General Purpose Representation drop-down list box. |
To find these options in the development environment, click Settings on the Project menu. Then click the C/C++ tab, and click C++ Language in the Category box. See the choices under Representation Method.
If you define a class before declaring a pointer to a member of the class using the Best-Case Always option, the compiler knows the kind of inheritance used by the class when it encounters the declaration of the pointer. Thus, it can use the smallest possible representation of a pointer and create the smallest amount of code required to operate on the pointer for each kind of inheritance.
With the Best-Case Always option, the compiler issues an error if it encounters the pointer declaration before the class definition. In this case, you must either reorganize your code or use the General-Purpose Always (/vmg) option. You can also use the pointers_to_members pragma or define the class using the __single_inheritance, __multiple_inheritance, or __virtual_inheritance keyword. These keywords allow control of the code created on a per-class basis.
For the Best-Case Always option, the corresponding argument to #pragma pointers_to_members is best_case.
For information on the use of the __single_inheritance, __multiple_inheritance, and __virtual_inheritance keywords, see Inheritance Keywords in the Language Quick Reference.