Standard Attributes in C and C++ – Timur Doumler – ACCU 2023



Standard Attributes in C and C++ – Timur Doumler – ACCU 2023

Standard Attributes in C and C++ - Timur Doumler - ACCU 2023

ACCU Membership: https://tinyurl.com/ydnfkcyn
Sponsored By think-cell: https://www.think-cell.com/en/
https://accu.org

Standard Attributes in C and C++ – Timur Doumler – ACCU 2023
Slides: https://accu.org/conf-previous/accu2023/

This talk is an in-depth tour of the standard attributes currently available in the C and C++ programming languages.

Some attributes such as deprecated, fallthrough, nodiscard, and maybe_unused are very helpful to produce or suppress warnings. Others, such as likely and unlikely, can be used as optimisation hints to the compiler, although it can be difficult to avoid misuse and accidentally pessimise your code instead. The attributes noreturn and assume can even inject undefined behaviour into your code. And then there is no_unique_address, which can be used to optimise the class layout, but comes with its own caveats regarding portability across major compilers.

C++ has had standard attributes since C++11, and every new standard is adding more. The C language introduced attributes in C23, adopted many attributes from C++, and added two new attributes exclusive to C: unsequenced and reproducible.

In this talk, we will describe the syntax and semantics of all existing standard attributes, including the latest additions in C23 and C++23, discuss the use cases for each one, show practical code examples, and offer guidelines on how to use them safely and effectively. We will also talk about the often-misunderstood C++ language design rule that attributes are “ignorable” and what that actually means.

Timur Doumler

Timur Doumler is the Developer Advocate for C++ tools at JetBrains and co-host of CppCast. He is an active member of the ISO C++ standard committee, where he is currently co-chair of the Contracts study group. As a developer, he worked many years in the audio and music technology industry and co-founded the music tech startup Cradle. Timur is passionate about clean code, good tools, low latency, and the evolution of the C++ language.

https://www.accuconference.org/

YouTube Videos Filmed, Edited & Optimised by Digital Medium: https://events.digital-medium.co.uk

#accuconf #programming #cpp