Pragmas are "directives" for the compiler, which affect the compilation process.
The "once" pragma normally (always?) is used at the beginning of an .h file that will be included in other .c or .cpp (or even other .hp) source files. This pragma instructs the compiler to read this file only once, even if the compilation flow of a source implies its reading more than once.
For example:
there is an include file "a.h", with the pragma "once" in the first line
there is an include file "b.h" which includes "a.h"
there is an include file "c.h" which includes "a.h"
There is a "p.c" file that includes "b.h" and "c.h"
The compiler, reading "p.c", includes (reads) "b.h", and reading "b.h" also includes "a.h". Then the compiler (still processing "pc") includes "ch" and discovers that it should include "ah", but as "ah" has already been included in "bh", no new "ah" inclusion is made. p>
The "pack" pragma controls the alignment of members of a structure. Usually, for reasons of efficiency a struct like this:
struct
{
char c;
int i;
} s;
has a 3-byte "hole" between "c" and "i", to "align" the "i" address to a multiple address of 4, since it is usually more efficient for the processor to access an "int" which has a multiple address of 4.
Using a pragma pack (1), for example, we can avoid the occurrence of these "holes" at the cost of a probable inefficiency in accessing the "i" member of the structure.
#pragma pack(1) // força alinhamento de 1
struct
{
char c;
int i;
} s;
#pragma pack() // volta o alinhamento default
The "comment" pragma if I am not mistakenly embeds strings in the executable code, but I'm not sure.