Похожие чаты

How do I overload macros?

39 ответов

35 просмотров

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

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта