Похожие чаты

How do I overload macros?

39 ответов

20 просмотров

You don't. You just redefine them wherever you need them. Latest definition will hide previous one.

Nils- Автор вопроса
Nils
ohz

Try avoiding macros. With modern C++ there are less and less things that require macro

Ihor
Try avoiding macros. With modern C++ there are les...

disagreed, there are things that modern c++ is unable to do and macros can, for example stringyfication

you cannot overload macros, but you can use macros with variable arguments, like: #define TEST(...) __VA_ARGS__

Alejandro
on avoiding macros

You should avoid them as much as possible

Alejandro
on avoiding macros

You may disagree as much as want but lots of developers agree with my opinion. Even the guy who invented the language https://stroustrup.com/bs_faq2.html#macro

Ihor
You may disagree as much as want but lots of devel...

stroustrup != the guy who invented c where macros come from

Alejandro
disagreed, there are things that modern c++ is una...

When they will add things like reflections?

Deni
How?

macros and template metaprogramming

Pavel
+ code generation

Literally, i created my telegram bot api parsing the telegram api site and writing c++ code with c++ code, it was awesome

Deni
Literally, i created my telegram bot api parsing t...

that's cool, I really enjoy metaprogramming too

Ihor
You may disagree as much as want but lots of devel...

Read “stroustrup” again.. he says.. “So, what's wrong with using macros?” What he’s talking about is the limitations of “macros”; and it’s limited functionality. And also read the last two sentences..

Aakash Saini
Read “stroustrup” again.. he says.. “So, what's wr...

Like wise you cannot use int for float/double calculations; like wise!! Every thing is precisely put to work accordingly in C/C+... modifying it otherwise you end up with “undefined behavior”.

Aakash Saini
Like wise you cannot use int for float/double calc...

Same way, likewise, you cannot make function(horses) act as macro(mules). 😄

Aakash Saini
Same way, likewise, you cannot make function(hors...

Lol, why call them mules? They are dragons, they can produce horses too 😝

Aakash Saini
Read “stroustrup” again.. he says.. “So, what's wr...

He is talking about then not having a scope, not following language rule and that macros won't be improved or developed further. Language features are added to standard to all the time to make macros less and less relevant. 1 You can not debug macros. 2 Macro expansion can lead to strange side effects. 3 Macros have no "namespace", so if you have a macro that clashes with a name used elsewhere, you get macro replacements where you didn't want it, and this usually leads to strange error messages. 4 Macros may affect things you don't realize. Here are some arguments why you should avoid macros if possible: https://arne-mertz.de/2019/03/macro-evil/ https://www.reddit.com/r/cpp/comments/2kkzki/why_the_hate_for_macros/ https://scienceblogs.com/goodmath/2007/12/17/macros-why-theyre-evil I can go on and go on.

Danya🔥
Hoping for C++26

If you want to try reflection in C++ This guy created a library with his C++14 voodoo magic that supports some form of reflection https://youtu.be/abdeAew3gmQ Link to repo : https://github.com/apolukhin/magic_get

Danya🔥
I know Antony

After watching his talk I understood even more how little C++ I know 😂

Ihor
He is talking about then not having a scope, not f...

Macro do have types of pitfalls; they also boycott the keyword mechanism.. To overcome complex macro/debug functionality inline & virtual are practiced for compile/runtime as considered. But macros are mules, we just can’t ignore their use as important directive. Complexity at macros are problematic; such practice should be avoided, that surely is concern. —> https://gcc.gnu.org/onlinedocs/cpp/Macro-Pitfalls.html#Macro-Pitfalls

Ihor
He is talking about then not having a scope, not f...

True, someone wrote a big Macro header file that once included allowed people to write code in python inside a cpp file 😂.

Kuntal M
* laughs in Qt *

* laughs while looking at GTK4 *

Kuntal M
you should be crying tbh

nahhh the tears have dried up... laughter only remains...

Похожие вопросы

Обсуждают сегодня

Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
For all those that keep asking why no pump? why this ? and why that...? Please close ur ewt chart and open 2 others - TOTAL (total mc) and BTC.D (btc dominance). Maybe BTC a...
Inn3r_G
19
"Since pnut can flip FTM easily, I'm swapping my FTM to pnut and hoping for a easy x5-x10" Perfect recipe for disaster. NFA but chances are, you'll end up as exit liquidity ...
C. A.
7
AMD status update? No longer in the plan but something might be around the corner later on Chinese partner? No longer in the plan. This market does not seem to be the top ...
Ben
6
I get confused when people talk about the ‘bull market’ and the ‘next bull market’ as if anyone really has a clue what’s really going on in the world. First of all - there i...
Shah
1
И никого не интересует какие пакеты кто использует. ((% Заходишь на сайт симфони и видишь поддержку Украины - по законам РФ это ж экстремизм. Только никто не отказывается от с...
Am Ambrion
11
Мне вот любопытно. Уже сколько времени имею соблазн купить макбук, ибо подозреваю что очень уж удобен будет в связке с другой техникой от эпл которая у меня есть, да и сам по ...
Not Yeromin
9
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
Добрый день, подскажите, пожалуйста, по проблеме. Сегодня на работе утром обнаружилось что по рдп подключиться не получается к серверу 2022. В серверную зашел - на системно...
srv
19
лучше скажите, причём тут паскаль?
Alexey Kulakov
36
Карта сайта