C tips for C++ developers part 1: compound literals, designated initializers, and forward declarations
This is the first post in my C tips for C++ developers series. I spend most of my time in C++, but lately I’ve been working on an embedded project where part of the codebase is pure C. Along the way I stumbled into a feature that made me pause and think “wait, you can do that in C?” I was writing a function to validate BLE advertising parameters and realized I could return a fully initialized struct in a single expression, almost exactly the way I would in C++. That caused me to gather more C features I had either forgotten or never learned properly into this series. ...