📚Загадочная библиотека setjmp.h — неочевидный инструмент для управления потоком выполнения
Библиотека setjmp.h предоставляет два необычных макроса:
• setjmp — сохраняет текущее состояние программы (регистры, стек) в буфер jmp_buf
• longjmp — «откатывает» выполнение к сохранённому состоянию, как прыжок во времени
#include <stdio.h> #include <setjmp.h>
jmp_buf jump_buffer;
void risky_function() { printf("Готовимся к прыжку...\n"); longjmp(jump_buffer, 42); // Прыжок обратно в setjmp! }
int main() { int ret = setjmp(jump_buffer); if (ret == 0) { printf("Первая инициализация...\n"); risky_function(); } else { printf("Вернулись с кодом: %d\n", ret); // Выведет 42! } return 0; }
⚠️Осторожно!
• Не заменяет исключения — нет вызова деструкторов (как в C++) • Опасность утечек — если между setjmp и longjmp выделялась память, она не освободится • Портит стек — может сломать логику функций
🛠Где может пригодиться?
• Обработка критических ошибок (а-ля «аварийный выход») • Код для встраиваемых систем, где нужно быстро восстановить состояние • Нестандартные хаки (но лучше так не делать 😈)
📚Загадочная библиотека setjmp.h — неочевидный инструмент для управления потоком выполнения
Библиотека setjmp.h предоставляет два необычных макроса:
• setjmp — сохраняет текущее состояние программы (регистры, стек) в буфер jmp_buf
• longjmp — «откатывает» выполнение к сохранённому состоянию, как прыжок во времени
#include <stdio.h> #include <setjmp.h>
jmp_buf jump_buffer;
void risky_function() { printf("Готовимся к прыжку...\n"); longjmp(jump_buffer, 42); // Прыжок обратно в setjmp! }
int main() { int ret = setjmp(jump_buffer); if (ret == 0) { printf("Первая инициализация...\n"); risky_function(); } else { printf("Вернулись с кодом: %d\n", ret); // Выведет 42! } return 0; }
⚠️Осторожно!
• Не заменяет исключения — нет вызова деструкторов (как в C++) • Опасность утечек — если между setjmp и longjmp выделялась память, она не освободится • Портит стек — может сломать логику функций
🛠Где может пригодиться?
• Обработка критических ошибок (а-ля «аварийный выход») • Код для встраиваемых систем, где нужно быстро восстановить состояние • Нестандартные хаки (но лучше так не делать 😈)
You can’t. What you can do, though, is use WhatsApp’s and Telegram’s web platforms to transfer stickers. It’s easy, but might take a while.Open WhatsApp in your browser, find a sticker you like in a chat, and right-click on it to save it as an image. The file won’t be a picture, though—it’s a webpage and will have a .webp extension. Don’t be scared, this is the way. Repeat this step to save as many stickers as you want.Then, open Telegram in your browser and go into your Saved messages chat. Just as you’d share a file with a friend, click the Share file button on the bottom left of the chat window (it looks like a dog-eared paper), and select the .webp files you downloaded. Click Open and you’ll see your stickers in your Saved messages chat. This is now your sticker depository. To use them, forward them as you would a message from one chat to the other: by clicking or long-pressing on the sticker, and then choosing Forward.
How To Find Channels On Telegram?
There are multiple ways you can search for Telegram channels. One of the methods is really logical and you should all know it by now. We’re talking about using Telegram’s native search option. Make sure to download Telegram from the official website or update it to the latest version, using this link. Once you’ve installed Telegram, you can simply open the app and use the search bar. Tap on the magnifier icon and search for a channel that might interest you (e.g. Marvel comics). Even though this is the easiest method for searching Telegram channels, it isn’t the best one. This method is limited because it shows you only a couple of results per search.