Naming Convention In Bitcoin Source Code

0

Is there specific reference for naming conventions in Bitcoin Core source code?
I see regularity in class naming with prefix "C" (Chain, CInv etc.) or pointer naming with "p" (pprev, pnode etc. ) and am wondering if there's more to my list of prefixes or other conventions.

Is there a Bitcoin-specific naming convention at all?

Aliakbar Ahmadi

Posted 2015-05-28T12:47:46.377

Reputation: 1 335

2

I don't know if there's a formal reference, but the second thing you're describing is http://en.wikipedia.org/wiki/Hungarian_notation

Nick ODell 2015-05-28T13:01:09.340

1

The bitcoin repo specifies their conventions here as well: https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md

morsecoder 2015-05-28T14:12:34.193

Answers

4

http://en.wikipedia.org/wiki/Hungarian_notation

  • C stands for Class
  • p for Pointer
  • f for Flag (boolean)
  • n for Number
  • sz for zero terminated string

These conventions are no longer mandatory when contributing to bitcoin core.

You might also read https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md

Jonas Schnelli

Posted 2015-05-28T12:47:46.377

Reputation: 5 465

1

The style guide for Bitcoin Core is available on GitHub here. It no longer details a naming convention, but as Nick ODell already mentioned above, variables typically follow a form of Apps Hungarian naming.

In the past, the style guide did include a naming convention, however it has since been removed because it wasn't being consistently followed.

Christopher Gurnee

Posted 2015-05-28T12:47:46.377

Reputation: 2 263