What is the use of "#pragma section <XYZ>"
in C ?
I have come across C code file where the following kind was used:-
#define XYZ "ITEM 26.G03"
#pragma section <XYZ>
where XYZ is: #define XYZ "ITEM 26.G03"
I need some explaination on the use of "#pragma section"
The
#pragma
directive is an implementation specific directive it is a standard way to provide additional information to the compiler. This directive has the following form:If the preprocessor recognizes the specified "name", it performs whatever action they stand for, or passes information on to the compiler. If "name" is not supported by the c implementation it's ignored.
For example gcc compiler accept the list of pragmas listed here.
For the
#pragma section
, the documentation of gcc said:More on that here.
Section creates a section in an .obj file.
Refer to MSDN for more details.
Code and data are generated in sections in an object file, combined by the linker into an executable file, and ultimately located in target memory at specific locations. Default sections are predefined and have certain attributes. The section pragmas may be used to change the default attributes, to define new sections, and to control the assignment of code and variables to particular sections and, along with the linker command file, their locations.
#pragma section
defines a section class, and optionally, one or two sections in the class. A section class controls the addressing and accessibility of variables and code placed in an instance of the class.