#pragma hashome (C++ only)

Category

Object code control

Purpose

Informs the compiler that the specified class has a home module that will be specified by #pragma ishome.

This class's virtual function table, along with certain inline functions, will not be generated as static. Instead, they will be referenced as externals in the compilation unit of the class in which #pragma ishome is specified.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-#--pragma--hashome--(--class_name--+------------+--)--------><
                                      '-allinlines-'      

Parameters

class_name
The name of a class to be referenced externally. class_name must be a class and it must be defined.
allinlines
Specifies that all inline functions from within class_name should be referenced as being external.

Usage

A warning will be produced if there is a #pragma ishome without a matching #pragma hashome.

Examples

In the following example, compiling the code samples will generate virtual function tables and the definition of S::foo() only for compilation unit a.o, but not for b.o. This reduces the amount of code generated for the application.
// a.h
struct S
{
   virtual void foo() {}

   virtual void bar();
};



// a.C
#pragma ishome(S)
#pragma hashome (S)

#include "a.h"

int main()
{
   S s;
   s.foo();
   s.bar();
}



// b.C
#pragma hashome(S)
#include "a.h"

void S::bar() {}

Related information