<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-declare-a-constant-in-c---mikhail-matrosov---ndc-techtown-2025-d8pukqmos" -->

---
title: How to declare a constant in C++ - Mikhail Matrosov -...
description: A comprehensive guide to declaring constants in C++ covering local and global constants, storage duration, linkage types, and the use of const, constexpr,...
canonical: https://daily.dev/posts/how-to-declare-a-constant-in-c---mikhail-matrosov---ndc-techtown-2025-d8pukqmos
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to declare a constant in C++ - Mikhail Matrosov - NDC TechTown 2025 | daily.dev
og:description: A comprehensive guide to declaring constants in C++ covering local and global constants, storage duration, linkage types, and the use of const, constexpr,...
og:url: https://daily.dev/posts/how-to-declare-a-constant-in-c---mikhail-matrosov---ndc-techtown-2025-d8pukqmos
og:image: https://api.daily.dev/og/posts/D8pUKQmoS.png
og:image:alt: How to declare a constant in C++ - Mikhail Matrosov - NDC TechTown 2025
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to declare a constant in C++ - Mikhail Matrosov - NDC TechTown 2025

**[NDC Conferences](https://daily.dev/sources/ndc)** · 51 min read · 0 upvotes · 0 comments

## Summary

A comprehensive guide to declaring constants in C++ covering local and global constants, storage duration, linkage types, and the use of const, constexpr, static, inline, and extern keywords. Explores how different specifiers affect binary size, initialization, cache usage, and ODR violations. Includes detailed assembly analysis showing optimization impacts, discusses anonymous namespaces for internal linkage, weak linkage for header files, and introduces C++20 modules with their different linkage semantics. Provides practical guidelines for each scenario with compiler explorer examples.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=dMkjJfQ7_xo>

## Similar posts on daily.dev

- [CppCon 2025 recording of my talk "Back to Basics: static, inline, const, and constexpr" is available](https://daily.dev/posts/cppcon-2025-recording-of-my-talk-back-to-basics-static-inline-const-and-constexpr-is-available-susufufxm) · Andreas Fertig · 2 upvotes · 0 comments

---

Tags: [#c++](https://daily.dev/tags/c++)

[View this post on daily.dev](https://daily.dev/posts/how-to-declare-a-constant-in-c---mikhail-matrosov---ndc-techtown-2025-d8pukqmos)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to declare a constant in C++ - Mikhail Matrosov - NDC TechTown 2025","url":"https://daily.dev/posts/how-to-declare-a-constant-in-c---mikhail-matrosov---ndc-techtown-2025-d8pukqmos","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-declare-a-constant-in-c---mikhail-matrosov---ndc-techtown-2025-d8pukqmos"},"datePublished":"2026-01-13T08:12:26.082Z","dateModified":"2026-01-13T08:18:01.861Z","description":"A comprehensive guide to declaring constants in C++ covering local and global constants, storage duration, linkage types, and the use of const, constexpr,...","image":"https://i.ytimg.com/vi/dMkjJfQ7_xo/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/dMkjJfQ7_xo/sddefault.jpg","isAccessibleForFree":true,"articleSection":"NDC Conferences","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"NDC Conferences","logo":"https://media.daily.dev/image/upload/s--SiIyojEj--/f_auto/v1748760369/logos/ndc","url":"https://daily.dev/sources/ndc"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-declare-a-constant-in-c---mikhail-matrosov---ndc-techtown-2025-d8pukqmos","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"c++","timeRequired":"PT51M","video":{"@type":"VideoObject","name":"How to declare a constant in C++ - Mikhail Matrosov - NDC TechTown 2025","description":"A comprehensive guide to declaring constants in C++ covering local and global constants, storage duration, linkage types, and the use of const, constexpr,...","thumbnailUrl":"https://i.ytimg.com/vi/dMkjJfQ7_xo/sddefault.jpg","uploadDate":"2026-01-13T08:12:26.082Z","duration":"PT51M","url":"https://api.daily.dev/r/D8pUKQmoS","embedUrl":"https://www.youtube.com/embed/dMkjJfQ7_xo"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"NDC Conferences","item":"https://daily.dev/sources/ndc"},{"@type":"ListItem","position":3,"name":"How to declare a constant in C++ - Mikhail Matrosov - NDC TechTown 2025"}]}
```

