util, refactor: Add UNIQUE_NAME helper macro #24355

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:220216-unique changing 5 files +11 −8
  1. hebasto commented at 1:01 PM on February 16, 2022: member

    This PR replaces repetitive code with a helper macro.

  2. util, refactor: Add UNIQUE_NAME helper macro
    This change replaces repetitive code with a helper macro.
    1633f5ec88
  3. laanwj commented at 1:29 PM on February 16, 2022: member

    Concept ACK I don't know enough about token concatenation and macros to be sure this still works as expected, though :smile:

  4. DrahtBot added the label Utils/log/libs on Feb 16, 2022
  5. laanwj commented at 8:58 PM on April 13, 2022: member

    Tested ACK 1633f5ec8846408182cceb60dc88f022635f4002

    diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
    index 9843382682579d9f65262b5a7dd7c81b5efa6340..7ae7aaf2035633bb4c0f31b22a6dbd8592be1b24 100644
    --- a/src/bitcoind.cpp
    +++ b/src/bitcoind.cpp
    @@ -30,6 +30,14 @@
     #include <functional>
     #include <optional>
     
    +#define NESTED_UNIQUE_NAME UNIQUE_NAME(uniquetest)
    +
    +int NESTED_UNIQUE_NAME;
    +int NESTED_UNIQUE_NAME;
    +int NESTED_UNIQUE_NAME;
    +int NESTED_UNIQUE_NAME;
    +int NESTED_UNIQUE_NAME;
    +
     using node::NodeContext;
     
     const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
    

    objdump -t output:

    0000000000000020 g     O .bss	0000000000000004 uniquetest6
    0000000000000024 g     O .bss	0000000000000004 uniquetest5
    0000000000000028 g     O .bss	0000000000000004 uniquetest4
    000000000000002c g     O .bss	0000000000000004 uniquetest3
    0000000000000030 g     O .bss	0000000000000004 uniquetest2
    
  6. laanwj merged this on Apr 13, 2022
  7. laanwj closed this on Apr 13, 2022

  8. hebasto deleted the branch on Apr 13, 2022
  9. sidhujag referenced this in commit a421cbae7a on Apr 14, 2022
  10. DrahtBot locked this on Apr 13, 2023
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me