Why should a developer use a macro?

  • Why should a developer use macro ?
  • What are the advantages and disadvantages of using them?
  • Where can I find resources and how to use them?
0
source share
11 answers

Macros are a pretty broad term. For example, in C ++ there are macros such as these . From a software development point of view, they allow you to use these convenience macros ( __FILE__for example) to do certain things, for example, get the name of the current source file, etc.

, . , , , , "" . , , .

+6

- , . , . , ; .

+6

  • , - , , .
  • ( , -)
+3

DRY ( ), - . , , , . , , .

:

  •  
  • .  
  • .

:

  • , .
  • stacktraces, , .
  • - MAX (x ++, y) x .
+1

- . .

:

  • -
  • ...

( , , API-, ).

+1

- . . , .

+1

, , , / ( )

:
- ( )
- ( - , 2 )
- geek-wannabe geek-ier

:
- ,
- /
- - /

+1

:

, . IntelliSense.

:

, , - , , 80-90 % , , -.

+1

Lisp Lisp, 7 8.

+1
source

A macro can be used as a template mechanism to minimize repetitive tasks, for example. cut / paste.

0
source

I use macros when inline code is faster than calling a function. This rarely matters to me now, with the exception of DSP programming. I used macros in assembly language and C. all the time.

0
source

All Articles