Description
The #pragma data_seg directive places static and external variables into the specified 32-bit data segment.
Syntax
All static and external variables defined after the #pragma data_seg directive are placed in the named data_segment. The pragma is in effect until the next #pragma data_seg directive or the end of the compilation unit. The quotation marks around data_segment and class are optional and provided for compatibility with Microsoft Visual C++. The #pragma data_seg directive can be overridden by the gen(dataseg, name) option.
Static and external variables defined before the first #pragma data_seg directive are placed in the default DATA32 segment, with the exception of uninitialzed variables and variables explicitly initialized to zero, which are placed in the BSS32 segment. You can also use #pragma data_seg to explicitly place variables in the DATA32 segment by specifying no data_segment, for example:
#pragma data_seg()
Because the variables in the BSS32 data segment are initialized at load time and loaded separately from the rest of your program, they take less space in your executable file. If you place these variables in a different data segment, this optimization does not take place, and the size of your executable module increases. For this reason, if the size of your executable file is critical to you, you should define all variables initialized to zero (either explicitly or by default) before the first occurrence of #pragma data_seg.
![]()
Preprocessor
Directives - An Overview
Preprocessor
Directive - #pragma
![]()
![]()
dataseg
Code Generation Option - gen(dataseg, name)
