#pragma alloc_text (OS/2, Windows)

The #pragma alloc_text directive lets you group functions into different 32-bit code segments.

The code_section is the name of the code segment where you want to place function. You can specify any number of functions to be included in the named code_section.

Functions that are not grouped in a code segment by #pragma alloc_text are placed in the default 32-bit code segment CODE32, or whatever was specified on the / NT option. You can also use #pragma alloc_text to explicitly place functions in CODE32 by specifying it as the code_section.

Defining your own code segments allows you to organize functions in memory so that the working set requires fewer pages of memory. You can also specify attributes for each segment, such as execute-only or preload. You specify attributes for code segments in a module definition (.DEF) file.

For example, to create two code segments, one load on call, the other preload:

    #pragma alloc_text(pl_seg, func1)
    #pragma alloc_text(loc_seg, func2)

and use the following statement in the .DEF file for the program:

    SEGMENTS

      pl_seg PRELOAD