Getting a basic und...
 
Notifications
Clear all

Getting a basic understanding of arduino  

 

admin
(@admin)
Admin
Joined: 3 months ago
Posts: 61

Quote
admin
(@admin)
Admin
Joined: 3 months ago
Posts: 61
18/06/2020 4:48 pm  

Macros are basically just textual substitutions in your code, and they get substituted into your code by the precompiler *before* the compiler interprets and converts your C code.

Definition : macro

A macro name is an abbreviation, which stands for some related lines of code. Macros are useful for the following purposes:

· To simplify and reduce the amount of repetitive coding

· To reduce errors caused by repetitive coding

· To make an assembly program more readable.

A macro consists of name, set of formal parameters and body of code. The use of macro name with set of actual parameters is replaced by some code generated by its body. This is called macro expansion.

Macros allow a programmer to define pseudo operations, typically operations that are generally desirable, are not implemented as part of the processor instruction, and can be implemented as a sequence of instructions. Each use of a macro generates new program instructions, the macro has the effect of automating writing of the program.

Macros can be defined used in many programming languages, like C, C++ etc. Example macro in C programming.Macros are commonly used in C to define small snippets of code. If the macro has parameters, they are substituted into the macro body during expansion; thus, a C macro can mimic a C function. The usual reason for doing this is to avoid the overhead of a function call in simple cases, where the code is lightweight enough that function call overhead has a significant impact on performance.

This post was modified 2 weeks ago by admin

ReplyQuote
Share:

©2020 LocalAd

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Log in with your credentials

or    

Forgot your details?

Create Account