edk2/NetworkPkg
Michael Kubacki 58de02af29 NetworkPkg: Replace include guards with #pragma once
Replace traditional `#ifndef`/`#define`/`#endif` include guards with
`#pragma` once.

`#pragma once` is a widely supported preprocessor directive that
prevents header files from being included multiple times. It is
supported by all toolchains used to build edk2: GCC, Clang/LLVM, and
MSVC.

Compared to macro-based include guards, `#pragma once`:

- Eliminates the risk of macro name collisions or copy/paste errors
  where two headers inadvertently use the same guard macro.
- Eliminate inconsistency in the way include guard macros are named
  (e.g., some files use `__FILE_H__`, others use `FILE_H_`, etc.).
- Reduces boilerplate (three lines replaced by one).
- Avoids polluting the macro namespace with guard symbols.
- Can improve build times as the preprocessor can skip re-opening the
  file entirely, rather than re-reading it to find the matching
  `#endif` ("multiple-include optimization").
  - Note that some compilers may already optimize traditional include
    guards, by recognzining the idiomatic pattern.

This change is made acknowledging that overall portability of the
code will technically be reduced, as `#pragma once` is not part of the
C/C++ standards.

However, this is considered acceptable given:

1. edk2 already defines a subset of supported compilers in
   BaseTools/Conf/tools_def.template, all of which have supported
   `#pragma once` for over two decades.
2. There have been concerns raised to the project about inconsistent
   include guard naming and potential macro collisions.

Approximate compiler support dates:

- MSVC: Supported since Visual C++ 4.2 (1996)
- GCC: Supported since 3.4 (2004)
  (http://gnu.ist.utl.pt/software/gcc/gcc-3.4/changes.html)
- Clang (LLVM based): Since initial release in 2007

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-02-23 21:01:28 +00:00
..
Application/VConfig NetworkPkg: Use the newly introduced ShellPrintHiiDefaultEx() alias 2025-10-01 10:02:57 +02:00
ArpDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Dhcp4Dxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Dhcp6Dxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
DnsDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
DpcDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
HttpBootDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
HttpDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
HttpUtilitiesDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Include NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Ip4Dxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Ip6Dxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
IScsiDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Library NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
MnpDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Mtftp4Dxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Mtftp6Dxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
SnpDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
TcpDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Test NetworkPkg: Add VS2026 toolchain support 2026-01-07 20:19:12 +00:00
TlsAuthConfigDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
TlsDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Udp4Dxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Udp6Dxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
UefiPxeBcDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
VlanConfigDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
WifiConnectionManagerDxe NetworkPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Network.dsc.inc NetworkPkg: Drop ARM32 Support 2025-09-25 22:04:10 +00:00
Network.fdf.inc NetworkPkg: PXE boot option build flag 2024-12-06 18:26:01 +00:00
NetworkBuildOptions.dsc.inc NetworkPkg: Remove RVCT support 2022-05-13 14:58:54 +00:00
NetworkComponents.dsc.inc NetworkPkg: PXE boot option build flag 2024-12-06 18:26:01 +00:00
NetworkDefines.dsc.inc NetworkPkg: PXE boot option build flag 2024-12-06 18:26:01 +00:00
NetworkDynamicPcds.dsc.inc OvmfPkg,ArmVirtPkg,NetworkPkg: Fix build with -D NETWORK_ENABLE=0 2025-11-21 12:08:00 +01:00
NetworkFixedPcds.dsc.inc NetworkPkg: mark fixed network PCDs 2024-11-11 13:38:51 +00:00
NetworkLibs.dsc.inc NetworkPkg: Add Http IO Helper Library to NetworkPkg 2020-12-04 11:45:07 +00:00
NetworkPkg.ci.yaml NetworkPkg: PXE boot option build flag 2024-12-06 18:26:01 +00:00
NetworkPkg.dec NetworkPkg: Add PCD to control http boot enable or disable. 2025-06-11 19:07:48 +00:00
NetworkPkg.dsc NetworkPkg: Add RngLib mapping for LOONGARCH64 2025-12-29 17:07:36 +00:00
NetworkPkg.uni NetworkPkg: Add PCD for HTTP transfer buffer size 2025-04-29 04:57:14 +00:00
NetworkPkgExtra.uni NetworkPkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:15 -07:00
SecurityFixes.yaml NetworkPkg TcpDxe: SECURITY PATCH CVE-2023-45236 2024-05-24 15:48:52 +00:00