DIFFERENT BETWEEN MACRO AND FUNCTION

Macro

Function

Macro is preprocessed

Function is compiled

No type checking

Type checking is done

Code length increases

Code length remains same

Use of macro can lead to side effect

No side effect

Speed of execution is faster

During function call, transfer of control takes place

Useful where small code appears many time

Useful where large code appears many time

Generally Macros do not extend beyond one line

Function can be of any number of lines

Macro does not check compile errors

Function checks compile errors

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s