Freigeben über


code_seg

Specifies the segment where functions are stored in the .obj file.

#pragma code_seg( [ [ { push | pop}, ] [ identifier, ] ] [ "segment-name" [, "segment-class" ] )

Remarks

The meaning of the terms segment and section are interchangeable in this topic.

OBJ files can be viewed with the dumpbin application. The default segment in the .obj file for functions is .text.

code_seg with no parameters resets the segment to .text.

  • push(optional)
    Puts a record on the internal compiler stack. A push can have an identifier and segment-name.

  • pop (optional)
    Removes a record from the top of the internal compiler stack.

  • identifier (optional)
    When used with push, assigns a name to the record on the internal compiler stack. When used with pop, pops records off the internal stack until identifier is removed; if identifier is not found on the internal stack, nothing is popped.

    identifier enables multiple records to be popped with a single pop command.

  • "segment-name"(optional)
    The name of a segment*.* When used with pop, the stack is popped and segment-name becomes the active segment name.

  • "segment-class" (optional)
    Included for compatibility with C++ prior to version 2.0. It is ignored.

Example

// pragma_directive_code_seg.cpp
void func1() {                  // stored in .text
}

#pragma code_seg(".my_data1")
void func2() {                  // stored in my_data1
}

#pragma code_seg(push, r1, ".my_data2")
void func3() {                  // stored in my_data2
}

#pragma code_seg(pop, r1)      // stored in my_data1
void func4() {
}

int main() {
}

See /SECTION for a list of names you should not use when creating a section.

You can also specify sections for initialized data (data_seg), uninitialized data (bss_seg), and const variables (const_seg).

See Also

Reference

Pragma Directives and the __Pragma Keyword