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


C geek 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.

Newly uncovered hack campaign in Telegram

The campaign, which security firm Check Point has named Rampant Kitten, comprises two main components, one for Windows and the other for Android. Rampant Kitten’s objective is to steal Telegram messages, passwords, and two-factor authentication codes sent by SMS and then also take screenshots and record sounds within earshot of an infected phone, the researchers said in a post published on Friday.

C geek from kr


Telegram C++ geek
FROM USA