0
What is macros and what are its role in computer??
10 Answers
+ 1
Macros is a set of user actions repeated by some tool. For example in MS Excel you can record user manipulations, and play them when you need like fill specific cells, or adding columns and rows. In linux such things done with bash scripts, you can automate some repetitive actions.
+ 5
Macros are automated functions that runs for a set of data
+ 2
In C++ macros are alias to prevent from copying the code too many time.
The preprocessor will replace the call of the macro by what it represent
- 1
One application:
#define your_macro
#ifdef your_macro
//true, we just defined it
//write your code here which is just evaluated if your_macro is defined
#endif
Other application:
#define your_macro some code snippet
Whenever you write your_macro, it is replaced with some code snippet. #ifdef works also, of course.
Note: Macros work across files.
- 1
@Martin Taylor This isn't a guard at all, it's just a sample. Noone uses #ifndef guards now anyways but #pragma once.
- 1
Yes, but this question is tagged c++.
- 1
Where isn't it supported?