2

Why Bitcoin Core source code use #include <rpc/wallet.h> bracket syntax instead of #include "rpc/wallet.h" quote syntax. Can intellisense C++ editors understand this option and not show a warning?

1 Answer 1

7

Double quotes means that the compiler will search for the include relative to the source file. Angle brackets means the compiler will search only the include paths. By using angle brackets and including all of the header files in the include path, the paths given in the include will always need to be relative to the project's source root.

The purpose of doing this is to reduce developer confusion as there are several files in different directories that are named the same. Requiring the include path to be relative to the source root, it becomes unambiguous as to which file is being included.

The PR that implemented this was (a rebase of) https://github.com/bitcoin/bitcoin/pull/11053, and that links to other discussions for motivation.

2
  • Is there a CLANG flag to avoid this message in Vim? `'bech32.h' file not found with <angled> include; use "quotes" instead" Aug 28, 2022 at 15:02
  • 1
    You need to make sure the project's src/ directory is in the include paths. For clang, if running in src/, that'd just be -I.. Aug 28, 2022 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.