This event has ended. Visit the official site or create your own event on Sched.
Friday, September 29 • 10:30am - 11:00am
What C++ developers should know about globals (and the linker)

Log in to save this to your schedule and see who's attending!

Feedback form is now closed.
Most C++ developers know that using globals (or singletons) excessively in code is usually a poor decision. But it is also hard to deny their usefulness in more than one situation: for loggers, factories, intrusive performance benchmarking, and other very useful applications, globals can be very helpful.

Unfortunately, usage of globals in C++ ends up exposing details of the language not seen so often otherwise. Instead of dealing with our tried-and-true, well specified compiler, we often need to look more at the behavior of the linker, which can vary more between platforms and between different options such as static vs dynamic linking.

This talk will look at some surprising pitfalls that can occur with globals: valid programs only a dozen lines long that can trigger segfaults when using the gcc linker. It will explore some of these issues using command line tools like nm and objdump. The talk will enumerate several pitfalls to be avoided. It will look at some of the different axes of the problem space such as: globals that are private versus public, eager versus lazy, global inter-dependencies, and quality of emitted assembly. Finally, solutions and idioms will be presented that address the major use cases, and make it easy for developers to use globals (only where necessary!) in a safe way.

avatar for Nir Friedman

Nir Friedman

Quantitative Developer, Tower Research Capital
After completing a PhD in physics, Nir started working doing C++ in low latency and high frequency trading. He's interested in the challenges of writing robust code at scale, and highly configurable code that minimizes performance trade-offs.

Friday September 29, 2017 10:30am - 11:00am
Berry Hall Meydenbauer Center

Attendees (232)