Hello all!

This time, our 79th meeting Oct 22 2025, we were hosting Hubert Liberacki who gave a fantastic presentation on “Cracking Open the Black Box: Legally Testing the Privates in C++”.

A huge thank you to everyone who attended and participated in the discussion!

For those who couldn’t make it or would like to review the talk, the full recording is available on YouTube:

About the presentation: Cracking Open the Black Box: Legally Testing the Privates in C++

Introduction: Encapsulation is a cornerstone of C++, yet private members often pose challenges in real projects. When refactoring legacy code, working with third party libraries, or debugging complex systems, gaining access to internals can be necessary to establish tests and enable a test driven workflow. In these situations, developers inevitably face the question of how to “test the privates” without breaking the rules.

Relevance: This is not an edge case but a recurring scenario in production code. Developers frequently reach for shortcuts such as #define private public or memory layout tricks. Those shortcuts are mostly undefined behavior leading to portability problems, or even changes in object layout across compilers. There are well known examples in widely used projects where such hacks have caused failures. This talk brings these issues into focus with real world references and demonstrates safer alternatives.

What did Hubert cover in this session:

  1. Why developers sometimes need access to private members (legacy code, third party libraries, debugging, instrumentation, and refactoring with TDD).
  2. Common techniques to achieve the access.
  3. Showcase (live) the dangerous side-effects: macro leakage, ABI mismatches, portability failures.
  4. Discovering the standard loophole.
  5. Live coding: step by step demonstration of this technique in practice, with explanations of how it works under the hood.
  6. Q&A and open discussion with attendees.

Completion state: Implementation is ready as github library – cpp-member-accessor

Support materials:

  1. https://github.com/nlohmann/json/issues/913 – “error due to #define private public”
  2. https://godbolt.org/z/Pjs1Y4cdv – “macro leak, size difference”
  3. https://pvs-studio.com/en/blog/posts/0146/ – “Your code can break”
  4. https://eel.is/c++draft/macro.names#2 – “It’s UB”

and one more: https://bloglitb.blogspot.com/2010/07/access-to-private-members-thats-easy.html?m=1

About the presenter: Hubert Liberacki

Hubert Liberacki is a Lead Software Engineer with over a decade of experience in C++ development across automotive and robotics, focusing on performance-critical and distributed systems.

At Apex.AI he worked on automotive-grade software-defined vehicle frameworks, and he is currently working at HERE Technologies on maps and rendering in large-scale C++ projects. His current interests also include Rust and its applications in high-performance and distributed systems.

A special thanks to our sponsors:

  • JetBrains for their generous and continued sponsorship of the San Diego C++ Meetup group.
  • Packt for providing exclusive discount codes to our attendees for their vast library of C++ books and resources.

Leave a Reply