Skip to content

refactor: Replace include guards by '#pragma once'#6322

Merged
bthomee merged 9 commits intodevelopfrom
bthomee/pragma
Feb 4, 2026
Merged

refactor: Replace include guards by '#pragma once'#6322
bthomee merged 9 commits intodevelopfrom
bthomee/pragma

Conversation

@bthomee
Copy link
Collaborator

@bthomee bthomee commented Feb 3, 2026

High Level Overview of Change

This change replaces all include guards in the src/ and include/ directories by #pragma once.

Context of Change

The use of traditional include guards, i.e.

#ifndef XXX
#define XXX

[code here]

#endif // XXX

is error prone (e.g. naming collisions, typos) and takes up a lot of space. The #pragma once directive overcomes these issues and is supported by the major compilers. Hence, this change serves to simplify our codebase and to reduce maintenance going forward.

Note that AI was used to create a script that performed the majority of these substitutions. However, as it made a few mistakes that needed manual fixing, I've not included the script in this PR. We will need to keep an eye out on currently open PRs to ensure any new files use #pragma once.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

@bthomee bthomee requested review from a team and Copilot February 3, 2026 19:37
@mvadari
Copy link
Collaborator

mvadari commented Feb 3, 2026

Should be easy enough to add a regex check to ensure these aren't included, right? Even without having a script that will replace successfully.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the header inclusion pattern by replacing traditional #ifndef/#define/#endif include guards with #pragma once across the include/ tree (and per description, also src/).

Changes:

  • Replaced include guards with #pragma once at the top of headers.
  • Removed trailing #endif guard terminators (and associated guard macro comments).
  • Standardized the header prolog across many modules (server/resource/protocol/ledger/beast/basics/etc.).

Reviewed changes

Copilot reviewed 300 out of 674 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
include/xrpl/server/detail/LowestLayer.h Replaces include guard with #pragma once
include/xrpl/server/detail/JSONRPCUtil.h Replaces include guard with #pragma once
include/xrpl/server/detail/Door.h Replaces include guard with #pragma once
include/xrpl/server/detail/BaseWSPeer.h Replaces include guard with #pragma once
include/xrpl/server/detail/BasePeer.h Replaces include guard with #pragma once
include/xrpl/server/detail/BaseHTTPPeer.h Replaces include guard with #pragma once
include/xrpl/server/Writer.h Replaces include guard with #pragma once
include/xrpl/server/WSSession.h Replaces include guard with #pragma once
include/xrpl/server/SimpleWriter.h Replaces include guard with #pragma once
include/xrpl/server/Session.h Replaces include guard with #pragma once
include/xrpl/server/Server.h Replaces include guard with #pragma once
include/xrpl/server/Port.h Replaces include guard with #pragma once
include/xrpl/server/Handoff.h Replaces include guard with #pragma once
include/xrpl/resource/detail/Tuning.h Replaces include guard with #pragma once
include/xrpl/resource/detail/Logic.h Replaces include guard with #pragma once
include/xrpl/resource/detail/Kind.h Replaces include guard with #pragma once
include/xrpl/resource/detail/Key.h Replaces include guard with #pragma once
include/xrpl/resource/detail/Import.h Replaces include guard with #pragma once
include/xrpl/resource/detail/Entry.h Replaces include guard with #pragma once
include/xrpl/resource/Types.h Replaces include guard with #pragma once
include/xrpl/resource/ResourceManager.h Replaces include guard with #pragma once
include/xrpl/resource/Gossip.h Replaces include guard with #pragma once
include/xrpl/resource/Fees.h Replaces include guard with #pragma once
include/xrpl/resource/Disposition.h Replaces include guard with #pragma once
include/xrpl/resource/Consumer.h Replaces include guard with #pragma once
include/xrpl/resource/Charge.h Replaces include guard with #pragma once
include/xrpl/protocol/tokens.h Replaces include guard with #pragma once
include/xrpl/protocol/st.h Replaces include guard with #pragma once
include/xrpl/protocol/serialize.h Replaces include guard with #pragma once
include/xrpl/protocol/nftPageMask.h Replaces include guard with #pragma once
include/xrpl/protocol/nft.h Replaces include guard with #pragma once
include/xrpl/protocol/messages.h Replaces include guard with #pragma once
include/xrpl/protocol/jss.h Replaces include guard with #pragma once
include/xrpl/protocol/json_get_or_throw.h Replaces include guard with #pragma once
include/xrpl/protocol/digest.h Replaces include guard with #pragma once
include/xrpl/protocol/detail/token_errors.h Replaces include guard with #pragma once
include/xrpl/protocol/detail/secp256k1.h Replaces include guard with #pragma once
include/xrpl/protocol/detail/b58_utils.h Replaces include guard with #pragma once
include/xrpl/protocol/detail/STVar.h Replaces include guard with #pragma once
include/xrpl/protocol/XRPAmount.h Replaces include guard with #pragma once
include/xrpl/protocol/XChainAttestations.h Replaces include guard with #pragma once
include/xrpl/protocol/Units.h Replaces include guard with #pragma once
include/xrpl/protocol/UintTypes.h Replaces include guard with #pragma once
include/xrpl/protocol/TxMeta.h Replaces include guard with #pragma once
include/xrpl/protocol/TxFormats.h Replaces include guard with #pragma once
include/xrpl/protocol/TxFlags.h Replaces include guard with #pragma once
include/xrpl/protocol/TER.h Replaces include guard with #pragma once
include/xrpl/protocol/SystemParameters.h Replaces include guard with #pragma once
include/xrpl/protocol/Sign.h Replaces include guard with #pragma once
include/xrpl/protocol/Serializer.h Replaces include guard with #pragma once
include/xrpl/protocol/SeqProxy.h Replaces include guard with #pragma once
include/xrpl/protocol/Seed.h Replaces include guard with #pragma once
include/xrpl/protocol/SecretKey.h Replaces include guard with #pragma once
include/xrpl/protocol/STXChainBridge.h Replaces include guard with #pragma once
include/xrpl/protocol/STVector256.h Replaces include guard with #pragma once
include/xrpl/protocol/STValidation.h Replaces include guard with #pragma once
include/xrpl/protocol/STTx.h Replaces include guard with #pragma once
include/xrpl/protocol/STTakesAsset.h Replaces include guard with #pragma once
include/xrpl/protocol/STPathSet.h Replaces include guard with #pragma once
include/xrpl/protocol/STParsedJSON.h Replaces include guard with #pragma once
include/xrpl/protocol/STObject.h Replaces include guard with #pragma once
include/xrpl/protocol/STNumber.h Replaces include guard with #pragma once
include/xrpl/protocol/STLedgerEntry.h Replaces include guard with #pragma once
include/xrpl/protocol/STIssue.h Replaces include guard with #pragma once
include/xrpl/protocol/STInteger.h Replaces include guard with #pragma once
include/xrpl/protocol/STExchange.h Replaces include guard with #pragma once
include/xrpl/protocol/STCurrency.h Replaces include guard with #pragma once
include/xrpl/protocol/STBlob.h Replaces include guard with #pragma once
include/xrpl/protocol/STBitString.h Replaces include guard with #pragma once
include/xrpl/protocol/STBase.h Replaces include guard with #pragma once
include/xrpl/protocol/STArray.h Replaces include guard with #pragma once
include/xrpl/protocol/STAmount.h Replaces include guard with #pragma once
include/xrpl/protocol/STAccount.h Replaces include guard with #pragma once
include/xrpl/protocol/SOTemplate.h Replaces include guard with #pragma once
include/xrpl/protocol/SField.h Replaces include guard with #pragma once
include/xrpl/protocol/Rules.h Replaces include guard with #pragma once
include/xrpl/protocol/RippleLedgerHash.h Replaces include guard with #pragma once
include/xrpl/protocol/Rate.h Replaces include guard with #pragma once
include/xrpl/protocol/RPCErr.h Replaces include guard with #pragma once
include/xrpl/protocol/QualityFunction.h Replaces include guard with #pragma once
include/xrpl/protocol/Quality.h Replaces include guard with #pragma once
include/xrpl/protocol/PublicKey.h Replaces include guard with #pragma once
include/xrpl/protocol/Protocol.h Replaces include guard with #pragma once
include/xrpl/protocol/Permissions.h Replaces include guard with #pragma once
include/xrpl/protocol/PayChan.h Replaces include guard with #pragma once
include/xrpl/protocol/NFTokenOfferID.h Replaces include guard with #pragma once
include/xrpl/protocol/NFTokenID.h Replaces include guard with #pragma once
include/xrpl/protocol/NFTSyntheticSerializer.h Replaces include guard with #pragma once
include/xrpl/protocol/MultiApiJson.h Replaces include guard with #pragma once
include/xrpl/protocol/MPTIssue.h Replaces include guard with #pragma once
include/xrpl/protocol/MPTAmount.h Replaces include guard with #pragma once
include/xrpl/protocol/LedgerHeader.h Replaces include guard with #pragma once
include/xrpl/protocol/LedgerFormats.h Replaces include guard with #pragma once
include/xrpl/protocol/KnownFormats.h Replaces include guard with #pragma once
include/xrpl/protocol/Keylet.h Replaces include guard with #pragma once
include/xrpl/protocol/KeyType.h Replaces include guard with #pragma once
include/xrpl/protocol/Issue.h Replaces include guard with #pragma once
include/xrpl/protocol/InnerObjectFormats.h Replaces include guard with #pragma once
include/xrpl/protocol/Indexes.h Replaces include guard with #pragma once
include/xrpl/protocol/IOUAmount.h Replaces include guard with #pragma once
include/xrpl/protocol/HashPrefix.h Replaces include guard with #pragma once
include/xrpl/protocol/Fees.h Replaces include guard with #pragma once
include/xrpl/protocol/Feature.h Replaces include guard with #pragma once
include/xrpl/protocol/ErrorCodes.h Replaces include guard with #pragma once
include/xrpl/protocol/BuildInfo.h Replaces include guard with #pragma once
include/xrpl/protocol/Book.h Replaces include guard with #pragma once
include/xrpl/protocol/Asset.h Replaces include guard with #pragma once
include/xrpl/protocol/ApiVersion.h Replaces include guard with #pragma once
include/xrpl/protocol/AmountConversions.h Replaces include guard with #pragma once
include/xrpl/protocol/AccountID.h Replaces include guard with #pragma once
include/xrpl/protocol/AMMCore.h Replaces include guard with #pragma once
include/xrpl/nodestore/detail/varint.h Replaces include guard with #pragma once
include/xrpl/nodestore/detail/codec.h Replaces include guard with #pragma once
include/xrpl/nodestore/detail/ManagerImp.h Replaces include guard with #pragma once
include/xrpl/nodestore/detail/EncodedBlob.h Replaces include guard with #pragma once
include/xrpl/nodestore/detail/DecodedBlob.h Replaces include guard with #pragma once
include/xrpl/nodestore/detail/DatabaseRotatingImp.h Replaces include guard with #pragma once
include/xrpl/nodestore/detail/DatabaseNodeImp.h Replaces include guard with #pragma once
include/xrpl/nodestore/detail/BatchWriter.h Replaces include guard with #pragma once
include/xrpl/nodestore/Types.h Replaces include guard with #pragma once
include/xrpl/nodestore/Task.h Replaces include guard with #pragma once
include/xrpl/nodestore/Scheduler.h Replaces include guard with #pragma once
include/xrpl/nodestore/NodeObject.h Replaces include guard with #pragma once
include/xrpl/nodestore/Manager.h Replaces include guard with #pragma once
include/xrpl/nodestore/Factory.h Replaces include guard with #pragma once
include/xrpl/nodestore/DummyScheduler.h Replaces include guard with #pragma once
include/xrpl/nodestore/DatabaseRotating.h Replaces include guard with #pragma once
include/xrpl/nodestore/Database.h Replaces include guard with #pragma once
include/xrpl/nodestore/Backend.h Replaces include guard with #pragma once
include/xrpl/net/RegisterSSLCerts.h Replaces include guard with #pragma once
include/xrpl/net/HTTPClientSSLContext.h Replaces include guard with #pragma once
include/xrpl/net/HTTPClient.h Replaces include guard with #pragma once
include/xrpl/net/AutoSocket.h Replaces include guard with #pragma once
include/xrpl/ledger/detail/ReadViewFwdRange.ipp Replaces include guard with #pragma once
include/xrpl/ledger/detail/ReadViewFwdRange.h Replaces include guard with #pragma once
include/xrpl/ledger/detail/RawStateTable.h Replaces include guard with #pragma once
include/xrpl/ledger/detail/ApplyViewBase.h Replaces include guard with #pragma once
include/xrpl/ledger/detail/ApplyStateTable.h Replaces include guard with #pragma once
include/xrpl/ledger/View.h Replaces include guard with #pragma once
include/xrpl/ledger/Sandbox.h Replaces include guard with #pragma once
include/xrpl/ledger/ReadView.h Replaces include guard with #pragma once
include/xrpl/ledger/RawView.h Replaces include guard with #pragma once
include/xrpl/ledger/PaymentSandbox.h Replaces include guard with #pragma once
include/xrpl/ledger/OpenView.h Replaces include guard with #pragma once
include/xrpl/ledger/Dir.h Replaces include guard with #pragma once
include/xrpl/ledger/Credit.h Replaces include guard with #pragma once
include/xrpl/ledger/CredentialHelpers.h Replaces include guard with #pragma once
include/xrpl/ledger/CachedView.h Replaces include guard with #pragma once
include/xrpl/ledger/CachedSLEs.h Replaces include guard with #pragma once
include/xrpl/ledger/BookDirs.h Replaces include guard with #pragma once
include/xrpl/ledger/ApplyViewImpl.h Replaces include guard with #pragma once
include/xrpl/ledger/ApplyView.h Replaces include guard with #pragma once
include/xrpl/json/to_string.h Replaces include guard with #pragma once
include/xrpl/json/json_writer.h Replaces include guard with #pragma once
include/xrpl/json/json_value.h Replaces include guard with #pragma once
include/xrpl/json/json_reader.h Replaces include guard with #pragma once
include/xrpl/json/json_forwards.h Replaces include guard with #pragma once
include/xrpl/json/json_errors.h Replaces include guard with #pragma once
include/xrpl/json/detail/json_assert.h Replaces include guard with #pragma once
include/xrpl/json/Writer.h Replaces include guard with #pragma once
include/xrpl/json/Output.h Replaces include guard with #pragma once
include/xrpl/json/JsonPropertyStream.h Replaces include guard with #pragma once
include/xrpl/crypto/secure_erase.h Replaces include guard with #pragma once
include/xrpl/crypto/csprng.h Replaces include guard with #pragma once
include/xrpl/crypto/RFC1751.h Replaces include guard with #pragma once
include/xrpl/core/detail/semaphore.h Replaces include guard with #pragma once
include/xrpl/core/detail/Workers.h Replaces include guard with #pragma once
include/xrpl/core/PerfLog.h Replaces include guard with #pragma once
include/xrpl/core/LoadMonitor.h Replaces include guard with #pragma once
include/xrpl/core/LoadEvent.h Replaces include guard with #pragma once
include/xrpl/core/JobTypes.h Replaces include guard with #pragma once
include/xrpl/core/JobTypeInfo.h Replaces include guard with #pragma once
include/xrpl/core/JobTypeData.h Replaces include guard with #pragma once
include/xrpl/core/JobQueue.h Replaces include guard with #pragma once
include/xrpl/core/Job.h Replaces include guard with #pragma once
include/xrpl/core/Coro.ipp Replaces include guard with #pragma once
include/xrpl/core/ClosureCounter.h Replaces include guard with #pragma once
include/xrpl/beast/xor_shift_engine.h Replaces include guard with #pragma once
include/xrpl/beast/utility/temp_dir.h Replaces include guard with #pragma once
include/xrpl/beast/utility/rngfill.h Replaces include guard with #pragma once
include/xrpl/beast/utility/maybe_const.h Replaces include guard with #pragma once
include/xrpl/beast/utility/instrumentation.h Replaces include guard with #pragma once
include/xrpl/beast/utility/Zero.h Replaces include guard with #pragma once
include/xrpl/beast/utility/WrappedSink.h Replaces include guard with #pragma once
include/xrpl/beast/utility/PropertyStream.h Replaces include guard with #pragma once
include/xrpl/beast/utility/Journal.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test/thread.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test/suite_list.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test/suite_info.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test/suite.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test/runner.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test/results.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test/reporter.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test/recorder.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test/match.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test/global_suites.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test/detail/const_container.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test/amount.h Replaces include guard with #pragma once
include/xrpl/beast/unit_test.h Replaces include guard with #pragma once
include/xrpl/beast/type_name.h Replaces include guard with #pragma once
include/xrpl/beast/test/yield_to.h Replaces include guard with #pragma once
include/xrpl/beast/rfc2616.h Replaces include guard with #pragma once
include/xrpl/beast/net/IPEndpoint.h Replaces include guard with #pragma once
include/xrpl/beast/net/IPAddressV6.h Replaces include guard with #pragma once
include/xrpl/beast/net/IPAddressV4.h Replaces include guard with #pragma once
include/xrpl/beast/net/IPAddressConversion.h Replaces include guard with #pragma once
include/xrpl/beast/net/IPAddress.h Replaces include guard with #pragma once
include/xrpl/beast/insight/StatsDCollector.h Replaces include guard with #pragma once
include/xrpl/beast/insight/NullCollector.h Replaces include guard with #pragma once
include/xrpl/beast/insight/MeterImpl.h Replaces include guard with #pragma once
include/xrpl/beast/insight/Meter.h Replaces include guard with #pragma once
include/xrpl/beast/insight/Insight.h Replaces include guard with #pragma once
include/xrpl/beast/insight/HookImpl.h Replaces include guard with #pragma once
include/xrpl/beast/insight/Hook.h Replaces include guard with #pragma once
include/xrpl/beast/insight/Groups.h Replaces include guard with #pragma once
include/xrpl/beast/insight/Group.h Replaces include guard with #pragma once
include/xrpl/beast/insight/GaugeImpl.h Replaces include guard with #pragma once
include/xrpl/beast/insight/Gauge.h Replaces include guard with #pragma once
include/xrpl/beast/insight/EventImpl.h Replaces include guard with #pragma once
include/xrpl/beast/insight/Event.h Replaces include guard with #pragma once
include/xrpl/beast/insight/CounterImpl.h Replaces include guard with #pragma once
include/xrpl/beast/insight/Counter.h Replaces include guard with #pragma once
include/xrpl/beast/insight/Collector.h Replaces include guard with #pragma once
include/xrpl/beast/hash/xxhasher.h Replaces include guard with #pragma once
include/xrpl/beast/hash/uhash.h Replaces include guard with #pragma once
include/xrpl/beast/hash/hash_append.h Replaces include guard with #pragma once
include/xrpl/beast/core/SemanticVersion.h Replaces include guard with #pragma once
include/xrpl/beast/core/LockFreeStack.h Replaces include guard with #pragma once
include/xrpl/beast/core/List.h Replaces include guard with #pragma once
include/xrpl/beast/core/LexicalCast.h Replaces include guard with #pragma once
include/xrpl/beast/core/CurrentThreadName.h Replaces include guard with #pragma once
include/xrpl/beast/container/detail/empty_base_optimization.h Replaces include guard with #pragma once
include/xrpl/beast/container/detail/aged_unordered_container.h Replaces include guard with #pragma once
include/xrpl/beast/container/detail/aged_ordered_container.h Replaces include guard with #pragma once
include/xrpl/beast/container/detail/aged_container_iterator.h Replaces include guard with #pragma once
include/xrpl/beast/container/detail/aged_associative_container.h Replaces include guard with #pragma once
include/xrpl/beast/container/aged_unordered_set.h Replaces include guard with #pragma once
include/xrpl/beast/container/aged_unordered_multiset.h Replaces include guard with #pragma once
include/xrpl/beast/container/aged_unordered_multimap.h Replaces include guard with #pragma once
include/xrpl/beast/container/aged_unordered_map.h Replaces include guard with #pragma once
include/xrpl/beast/container/aged_set.h Replaces include guard with #pragma once
include/xrpl/beast/container/aged_multiset.h Replaces include guard with #pragma once
include/xrpl/beast/container/aged_multimap.h Replaces include guard with #pragma once
include/xrpl/beast/container/aged_map.h Replaces include guard with #pragma once
include/xrpl/beast/container/aged_container_utility.h Replaces include guard with #pragma once
include/xrpl/beast/container/aged_container.h Replaces include guard with #pragma once
include/xrpl/beast/clock/manual_clock.h Replaces include guard with #pragma once
include/xrpl/beast/clock/basic_seconds_clock.h Replaces include guard with #pragma once
include/xrpl/beast/clock/abstract_clock.h Replaces include guard with #pragma once
include/xrpl/beast/asio/io_latency_probe.h Replaces include guard with #pragma once
include/xrpl/basics/tagged_integer.h Replaces include guard with #pragma once
include/xrpl/basics/strHex.h Replaces include guard with #pragma once
include/xrpl/basics/spinlock.h Replaces include guard with #pragma once
include/xrpl/basics/scope.h Replaces include guard with #pragma once
include/xrpl/basics/safe_cast.h Replaces include guard with #pragma once
include/xrpl/basics/rocksdb.h Replaces include guard with #pragma once
include/xrpl/basics/random.h Replaces include guard with #pragma once
include/xrpl/basics/partitioned_unordered_map.h Replaces include guard with #pragma once
include/xrpl/basics/mulDiv.h Replaces include guard with #pragma once
include/xrpl/basics/make_SSLContext.h Replaces include guard with #pragma once
include/xrpl/basics/join.h Replaces include guard with #pragma once
include/xrpl/basics/hardened_hash.h Replaces include guard with #pragma once
include/xrpl/basics/contract.h Replaces include guard with #pragma once
include/xrpl/basics/comparators.h Replaces include guard with #pragma once
include/xrpl/basics/chrono.h Replaces include guard with #pragma once
include/xrpl/basics/base_uint.h Replaces include guard with #pragma once
include/xrpl/basics/base64.h Replaces include guard with #pragma once
include/xrpl/basics/algorithm.h Replaces include guard with #pragma once
include/xrpl/basics/UptimeClock.h Replaces include guard with #pragma once
include/xrpl/basics/UnorderedContainers.h Replaces include guard with #pragma once
include/xrpl/basics/ToString.h Replaces include guard with #pragma once
include/xrpl/basics/TaggedCache.ipp Replaces include guard with #pragma once
include/xrpl/basics/TaggedCache.h Replaces include guard with #pragma once
include/xrpl/basics/StringUtilities.h Replaces include guard with #pragma once
include/xrpl/basics/Slice.h Replaces include guard with #pragma once
include/xrpl/basics/SlabAllocator.h Replaces include guard with #pragma once
include/xrpl/basics/SharedWeakCachePointer.ipp Replaces include guard with #pragma once
include/xrpl/basics/SharedWeakCachePointer.h Replaces include guard with #pragma once
include/xrpl/basics/SHAMapHash.h Replaces include guard with #pragma once
include/xrpl/basics/ResolverAsio.h Replaces include guard with #pragma once
include/xrpl/basics/Resolver.h Replaces include guard with #pragma once
include/xrpl/basics/RangeSet.h Replaces include guard with #pragma once
include/xrpl/basics/Number.h Replaces include guard with #pragma once
include/xrpl/basics/MathUtilities.h Replaces include guard with #pragma once
include/xrpl/basics/Log.h Replaces include guard with #pragma once
include/xrpl/basics/LocalValue.h Replaces include guard with #pragma once
include/xrpl/basics/KeyCache.h Replaces include guard with #pragma once
include/xrpl/basics/IntrusiveRefCounts.h Replaces include guard with #pragma once
include/xrpl/basics/IntrusivePointer.ipp Replaces include guard with #pragma once
include/xrpl/basics/IntrusivePointer.h Replaces include guard with #pragma once
include/xrpl/basics/FileUtilities.h Replaces include guard with #pragma once
include/xrpl/basics/Expected.h Replaces include guard with #pragma once
include/xrpl/basics/DecayingSample.h Replaces include guard with #pragma once
include/xrpl/basics/CountedObject.h Replaces include guard with #pragma once
include/xrpl/basics/CompressionAlgorithms.h Replaces include guard with #pragma once
include/xrpl/basics/ByteUtilities.h Replaces include guard with #pragma once
include/xrpl/basics/Buffer.h Replaces include guard with #pragma once
include/xrpl/basics/Blob.h Replaces include guard with #pragma once
include/xrpl/basics/BasicConfig.h Replaces include guard with #pragma once
include/xrpl/basics/Archive.h Replaces include guard with #pragma once

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#ifndef XRPL_PROTOCOL_ACCOUNTID_H_INCLUDED
#define XRPL_PROTOCOL_ACCOUNTID_H_INCLUDED
#pragma once

Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching from include guards to #pragma once removes the previously-defined guard macro (e.g. XRPL_PROTOCOL_ACCOUNTID_H_INCLUDED). That macro removal is an observable API change and can break any downstream code using these macros as feature-test/availability checks. If compatibility is required, consider adding a separate compatibility #define (without using it for guarding) near the top of the header or documenting/enforcing that these macros are not supported for consumers.

Suggested change
#ifndef XRPL_PROTOCOL_ACCOUNTID_H_INCLUDED
#define XRPL_PROTOCOL_ACCOUNTID_H_INCLUDED
#endif

Copilot uses AI. Check for mistakes.
@bthomee
Copy link
Collaborator Author

bthomee commented Feb 3, 2026

Should be easy enough to add a regex check to ensure these aren't included, right? Even without having a script that will replace successfully.

Fair. I simplified by only checking for #ifndef XRPL_ under the assumption that new files in open PRs will have include guards that start with XRPL_.

This script has been added to the collection of "rename" PRs as in my original proposal the possibility was raised of using #pragma once.

Copilot AI review requested due to automatic review settings February 3, 2026 20:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 300 out of 677 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +28
if grep -q "#ifndef XRPL_" "${FILE}"; then
echo "Please replace all include guards by #pragma once."
exit 1
fi
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guard detection only flags #ifndef XRPL_..., but this repo historically uses multiple guard prefixes (e.g. BEAST_..., PROTOCOL_..., JOIN_H_INCLUDED, etc.). To make the CI check effective, broaden the match to catch common include-guard patterns (e.g. #ifndef, #if !defined(...)) rather than assuming an XRPL_ prefix.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 3, 2026 20:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 300 out of 677 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +23 to +28
find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" \) | while read -r FILE; do
echo "Processing file: ${FILE}"
if grep -q "#ifndef XRPL_" "${FILE}"; then
echo "Please replace all include guards by #pragma once."
exit 1
fi
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guard check only matches #ifndef XRPL_, but this repo historically contains other guard prefixes (e.g. BEAST_, PROTOCOL_, etc.), so new include guards can slip through undetected. Consider updating the script to detect include guards more generally (e.g., scan only the first ~20 lines for an #ifndef immediately followed by #define, and exclude common non-guard #ifndef cases), and avoid per-file echo spam to keep CI logs readable.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense. Files like tagged_integer.h use macros not starting with XRPL_.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, but once this PR has been merged there are no non-XRPL_ include guards anymore. This check protects against open PRs that introduce new include guards, which presumably will start with XRPL_ since there'd be no reason to use any other prefix.

@bthomee bthomee requested review from a1q123456 February 3, 2026 20:12
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.9%. Comparing base (3a17230) to head (0a31a3b).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6322     +/-   ##
=========================================
- Coverage     79.9%   79.9%   -0.0%     
=========================================
  Files          840     840             
  Lines        65548   65548             
  Branches      7268    7264      -4     
=========================================
- Hits         52353   52350      -3     
- Misses       13195   13198      +3     
Files with missing lines Coverage Δ
include/xrpl/basics/BasicConfig.h 90.8% <ø> (ø)
include/xrpl/basics/Buffer.h 100.0% <ø> (ø)
include/xrpl/basics/ByteUtilities.h 100.0% <ø> (ø)
include/xrpl/basics/CompressionAlgorithms.h 0.0% <ø> (ø)
include/xrpl/basics/CountedObject.h 100.0% <ø> (ø)
include/xrpl/basics/DecayingSample.h 87.9% <ø> (ø)
include/xrpl/basics/Expected.h 100.0% <ø> (ø)
include/xrpl/basics/IntrusivePointer.h 91.7% <ø> (ø)
include/xrpl/basics/IntrusivePointer.ipp 86.6% <ø> (ø)
include/xrpl/basics/IntrusiveRefCounts.h 92.6% <ø> (ø)
... and 197 more

... and 233 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@godexsoft godexsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement.

@bthomee
Copy link
Collaborator Author

bthomee commented Feb 4, 2026

@dangell7 FYI

@bthomee bthomee merged commit 34ef577 into develop Feb 4, 2026
27 checks passed
@bthomee bthomee deleted the bthomee/pragma branch February 4, 2026 14:50
mvadari pushed a commit to mvadari/rippled that referenced this pull request Feb 4, 2026
This change replaces all include guards in the `src/` and `include/` directories by `#pragma once`.
mvadari pushed a commit that referenced this pull request Feb 4, 2026
This change replaces all include guards in the `src/` and `include/` directories by `#pragma once`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants