SPRU514Z July 2001 – October 2023 SM320F28335-EP
The once pragma tells the C preprocessor to ignore a #include directive if that header file has already been included. For example, this pragma may be used if header files contain definitions, such as struct definitions, that would cause a compilation error if they were executed more than once.
This pragma should be used at the beginning of a header file that should only be included once. For example:
// hdr.h
#pragma once
#warn You will only see this message one time
struct foo
{
int member;
};
This pragma is not part of the C or C++ standard, but it is a widely-supported preprocessor directive. Note that this pragma does not protect against the inclusion of a header file with the same contents that has been copied to another directory.