Похожие чаты

How do I overload macros?

39 ответов

6 просмотров

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

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

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

Hi everyone! I have a two-folded message to share today. First: updates and news, as we are being asked for those. We still want to go like we did the last 6 years: we w...
Marten | Unibright.io
31
комрады, че-та лыжы не едут var tmpFont: TFont; begin tmpFont:= TFont.Create; try case rgFontColor.ItemIndex of 0: tmpFont.Color:= clWindowText; 1: tmpFo...
Ed Doc
34
VIP-310 Set RedStone as the MAIN oracle for BTC and BNB on BNB Chain Summary If passed, this VIP will perform the following actions: - Configure RedStone as the MAIN oracle...
Venus Announcements
1
Интересно, нет ли какого-то способа получить из dll не адрес самой метки, а адрес со смещением?
The Bird of Hermes
54
monero is the only tool for privacy and currency . why would we destroy it?
😎
13
🔍 Launch of Sentinel dVPN's Native Explorer 🎉 The Sentinel Growth DAO is thrilled to announce the launch of Sentinel dVPN's new native blockchain explorer! Now anyone can div...
Joey | BadgerBite Joeyy
1
Можно вообще написать: Person fName' lName' age'. Тогда действительно имена полей потребуются лишь в строковом виде, чтобы эти fName' и т.д. достать :-) Но разве для этого нуж...
Михаил
8
Its been almost a week and the upgrade only went from 30% to 35%, why so slow?
Jackson
10
generic procedure function test<T>(param: T); type case T of longint: NewT = word; longword: NewT = byte; end; var v1: NewT; Как это можно сделать? Чтобы у меня...
notme
21
Whoa, did you guys see this FUNToken Seed Grant announcement? 💸
Noah Noure
37
Карта сайта