Telegram Group & Telegram Channel
👨‍💻 Сегодня покажу вам удобный способ, как избавиться от болей с #include в больших C++ проектах.

Когда проект растёт, количество инклудов становится пугающим. Компиляция тормозит, зависимости запутаны, порядок подключения начинает влиять на поведение программы… Знакомо?

📌 Решение — Precompiled Headers (PCH).

Это не магия, а вполне рабочая практика. Всё просто:

1. Создаём файл pch.h, в котором собираем самые часто используемые инклюды:

// pch.h
#pragma once
#include <iostream>
#include <vector>
#include <map>
// и т.д.


2. Добавляем его в компиляцию с флагом:

g++ -x c++-header pch.h -o pch.h.gch


3. Теперь любой другой файл, который первым инклудит pch.h, компилируется быстрее.

⚡️ Бонус: современные сборочные системы, вроде CMake, умеют работать с PCH почти автоматически. Достаточно:

target_precompile_headers(my_target PRIVATE pch.h)


🧠 Маленький совет: следите, чтобы в pch.h не попадали редко используемые или изменяющиеся файлы — иначе получите обратный эффект.

Пользовались ли вы PCH в своих проектах? Какой прирост производительности заметили?

➡️ @cpp_geek



tg-me.com/cpp_geek/305
Create:
Last Update:

👨‍💻 Сегодня покажу вам удобный способ, как избавиться от болей с #include в больших C++ проектах.

Когда проект растёт, количество инклудов становится пугающим. Компиляция тормозит, зависимости запутаны, порядок подключения начинает влиять на поведение программы… Знакомо?

📌 Решение — Precompiled Headers (PCH).

Это не магия, а вполне рабочая практика. Всё просто:

1. Создаём файл pch.h, в котором собираем самые часто используемые инклюды:


// pch.h
#pragma once
#include <iostream>
#include <vector>
#include <map>
// и т.д.


2. Добавляем его в компиляцию с флагом:

g++ -x c++-header pch.h -o pch.h.gch


3. Теперь любой другой файл, который первым инклудит pch.h, компилируется быстрее.

⚡️ Бонус: современные сборочные системы, вроде CMake, умеют работать с PCH почти автоматически. Достаточно:

target_precompile_headers(my_target PRIVATE pch.h)


🧠 Маленький совет: следите, чтобы в pch.h не попадали редко используемые или изменяющиеся файлы — иначе получите обратный эффект.

Пользовались ли вы PCH в своих проектах? Какой прирост производительности заметили?

➡️ @cpp_geek

BY C++ geek


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/cpp_geek/305

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

How to Buy Bitcoin?

Most people buy Bitcoin via exchanges, such as Coinbase. Exchanges allow you to buy, sell and hold cryptocurrency, and setting up an account is similar to opening a brokerage account—you’ll need to verify your identity and provide some kind of funding source, such as a bank account or debit card. Major exchanges include Coinbase, Kraken, and Gemini. You can also buy Bitcoin at a broker like Robinhood. Regardless of where you buy your Bitcoin, you’ll need a digital wallet in which to store it. This might be what’s called a hot wallet or a cold wallet. A hot wallet (also called an online wallet) is stored by an exchange or a provider in the cloud. Providers of online wallets include Exodus, Electrum and Mycelium. A cold wallet (or mobile wallet) is an offline device used to store Bitcoin and is not connected to the Internet. Some mobile wallet options include Trezor and Ledger.

What is Telegram?

Telegram’s stand out feature is its encryption scheme that keeps messages and media secure in transit. The scheme is known as MTProto and is based on 256-bit AES encryption, RSA encryption, and Diffie-Hellman key exchange. The result of this complicated and technical-sounding jargon? A messaging service that claims to keep your data safe.Why do we say claims? When dealing with security, you always want to leave room for scrutiny, and a few cryptography experts have criticized the system. Overall, any level of encryption is better than none, but a level of discretion should always be observed with any online connected system, even Telegram.

telegram from cn


Telegram C++ geek
FROM USA