Advantages and disadvantages of using macro and inline functions?

already exists.

Would you like to merge this question into it?

already exists as an alternate of this question.

Would you like to make it the primary and merge this question into it?

exists and is an alternate of .

Advantage: Macros and Inline functions are efficient than calling a normal function. The times spend in calling the function is saved in case of macros and inline functions as these are included directly into the code.

Disadvantage: Macros and inline functions increased the size of executable code.

Difference in inline functions and macro
1) Macro is expanded by preprocessor and inline function are expanded by compiler.
2) Expressions passed as arguments to inline functions are evaluated only once while _expression passed as argument to inline functions are evaluated more than once.

More over inline functions are used to overcome the overhead of function calls. Macros are used to maintain the readbility and easy maintainence of the code.
9 people found this useful

What are macros and what are its advantages and disadvantages?

Macros are preprocessor statements which will have specific set of instructions which are repeated in source code for several times and which wil be replaced at every call made. 1. Reduce source code length 2. Prog more readable. 3. Any modification to instructions in macro reflects in every (MORE)

What are the advantages of macros?

Answer . advantage is that it saves memory and time.because with the use of macros the compilation will become faster and it is very easy to change any value in the big program. Answer . The main advantage of using the macro is the speed of the execution of the program (if macro is not used (MORE)

What are the advantages and disadvantages of using petroleum?

There are numerous advantages to petroleum both as a fuel and as a raw material: . It has high energy density. You don't need mch to provide a significant amount of usable energy . Production systems are simple . Storage and transportation systems are simple . For transportation it feeds an es (MORE)

What are the advantages of using inline functions?

Suppose that you wish to write a function in C to compute the maximum of two numbers. One way would be to say: . int max(int a, int b){return (a > b ? a : b);}. But calling a frequently-used function can be a bit slow, and so you instead use a macro: . define max(a, b) ((a) > (b) ? (a) : (b)). T (MORE)

What is inline function?

Answer . it is the function declared inside the class. It is used for gaining faster speed in execution but it might give back the larger executable file . An inline function is one that is not called, its code is inserted in the position where you make a call to it. If it is called multiple ti (MORE)

What is the advantage and disadvantage of macros and in line functions?

Hi All,. I don't know exactly about it, but I want to share what I know. When we compile our file, macros and inline function calls get expanded, that is, calls get replaced with definition. It makes file bulky and consume more processor time. In case of macros, some problem other problems also occ (MORE)

Disadvantage of macros?

Macros are complicated to write. Someone needs a good knowledge tocreate them correctly. There is a risk of doing some damage to yourdata if you make a mistake.

What are the advantages and disadvantages of using glass?

Advantages: . Glass can be made into objects of different shapes or sizes. . Glass can be colourless or coloured. . Glass does not rust. . Glass does not let water to pass through. . Disadvantages: . Is is a very expensive material . It breaks easily. . It can melt under very high temperat (MORE)

What are the advantages and disadvantages of using spreadsheets?

The advantages of using a spreadsheet are; your date is organized and is setup in such away. That it is easy for any one to read and understand. Plus you can input the data into into any number of graphs and charts. which in my book looks more professional and my you look like you no what you are ta (MORE)

What are the Advantages and Disadvantage of using a telephone?

The advantages to using the telephone is that you can hear the callers voice, and often get a faster response. A disadvantage is that there is often no record of the call or what is said, so it is your word versus the callers word in a dispute over the content of the discussion.

Advantages and disadvantages of using HTML?

The answer to this question is opinion based. The main advantage to using HTML (Hyper Text Markup Language) is that it's user friendly and very productive for formatting different fonts in the same document. The disadvantage is that it is a basic code and cannot execute detail. You would have to use (MORE)

What are the advantages and disadvantages of using reservoirs?

Dams are extremely expensive to build and must be built to a very high standard. . The high cost of dam construction means that they must operate for many decades to become profitable. . The flooding of large areas of land means that the natural environment is destroyed. . People living in villag (MORE)

What is the function advantages disadvantages of telex?

telex has almost disappeared, superseded by the fax machine and email. The advantage over telegraph is that ordinary people could read the output (Latin alphabet cf. Morse code), and over the telephone that there was a written record and the recipient did not need to be present to receive a message. (MORE)

Advantages of inline function?

Inline functions are placed directly into the executable code instead of being called through a function pointer. Inline functions trade executable code size (which will be larger) for code execution speed (which will be faster). The decision to inline lies with the number of times the function is u (MORE)

What are the advantages and disadvantages for the function generator?

Advantage 1. Different waveform upto mhz freq. Can be generated 2. it can be used to generate square, sine, triangular and sawtoothwaveforms 3. calibration is internal. Disadvantage They are usually not suitable for applications that need lowdistortion or stable frequency signals.

Advantages and disadvantages of functional organisational structure?

FUNCTIONAL STRUCTURE . Salient points: · Functional structures typically work well for smaller and less complex organizations dealing with only one or a few products or services. · Also work best in relatively stable environments that allow organizations to pursue consistent strategies.. M (MORE)

What is advantage disadvantage of friend function in C?

C is not object oriented programming language thus there are no friend functions in C. In C++, which is object oriented, the advantage of a friend is that it allows code that cannot otherwise be regarded as being a member of the class to gain private access to the class representation, where public (MORE)

What is the use of inline function in c?

When you mark function as inline compiler puts the whole body of function in those places it is called, similar idea as in macros . If you do not mark function as inline compiler inside still decides which functions should be inline and which not. Inline function is less performance costly (MORE)

What are the advantages and disadvantages of PHP functions?

There are too many (hundreds) functions for there to be an answer to this. Advantages are that they can be used server side to print output that can be translated from databases etc. Disadvantages it that it can delay the loading time of all you pages.

Explain the advantages and disadvantages of friend functions?

by: THE DJ AK www.the-dj-ak.webs.com www.thedjak.co.nr www.thedjak.webs.com What is a Friend Function? A friend function is a special function in c++ which inspite of not being member fuction of a class has privalage to access private and protected data of a class. A friend function is a non mem (MORE)

Advantages of inline functions in c plus plus?

Inline functions execute quicker because the code is inline expanded by the compiler, thus eliminating unnecessary function calls. Function calls are expensive in terms of both memory and performance, so the fewer function calls there are, the better. However, there is a trade-off between fewer f (MORE)

Advantages and disadvantages of inline function?

it only increase performance for the code that the compiler output but with today's optimized compilers, fast CPUs, huge memory etc (not like in the 1980< where memory was scarce and everything had to fit in 100KB of memory

What are the advantages and disadvantages of using WikiAnswers?

Well, obviously one great disadvantage is that someone just might not know what they're talking about and answer a question incorrectly. Another disadvantage (Which in most cases) is that people who are getting these answers need to learn it themselves through studying and schoolwork instead of some (MORE)

Advantage and disadvantage of inline function in c plus plus?

The advantage of an inline function is that it eliminates the function calls completely, thus improving the performance wherever those calls appear. The disadvantage is that it increases code size, which can be detrimental to performance. For this reason, declaring a function for inline expansion is (MORE)

What is use of inline function in c plus plus?

An inline function is a sequence of code that the compiler generates in place of the equivalent function call setup, execution, and take down. This is useful for short functions that run so fast that the relative overhead of the function call sequence becomes significant. The downside is that the se (MORE)

What are the advantages and disadvantages of using CSS?

CSS separates the content that is in the HTML from the presentation aspects of the page(s) that is in the CSS. Advantages are that it is possible to reformat multiple pages by changing one external stylesheeet. I often use three, one basic one that contains rudimentary formats for elements, a speci (MORE)

What are the Advantages and disadvantages of using a manometer?

ADVANTAGES . Following are the advantages of Bourdon tubes : i) low cost ii) simple construction iii) time tested in applications iv) availability in a wide variety of ranges , including very high ranges v) adaptability to transducer designs for electronic instruments vi) high accuracy, especiall (MORE)

What is the use of INLINE function?

An inline function is a function that is inline expanded in your code during compilation, thus eliminating the overhead of a function call, whilst retaining the function itself for the purpose of code maintenance and readability. Declaring a function inline is no guarantee that it will be inline exp (MORE)

What is the difference between macro and inline function in c plus plus?

Macros are not actually part of the C++ language; they are nothing more than a simple text-replacement system intended to simplify your coding. Macros do not adhere to C++ type safety and cannot be debugged because macros are preprocessed, prior to compilation. Your compiler can only see the preproc (MORE)

What are the advantages and disadvantages of using a motorcycle?

Advantages: -lower fuel costs than a passenger vehicle -may not require emissions tests -most riders consider the actual riding to be fun and exciting -where legal, motorcycles can "split lanes" and avoid traffic -you may participate in rider clubs and events -some motorcycles can greatl (MORE)

What is the advantage or disadvantage of using ATM?

One advantage is that you don't have to go inside a bank. And one disadvantage of using the ATM is that you can not talk to the person, if the machine messes up. Using ATM machines has more advantages than disadvantages. ATMmachines are like a daily staple which is used every day to makewithdrawals (MORE)

What are the advantages and disadvantages of using lead?

Disadvantages: lead is very toxic, it's uses can result in pollution of the ground and more drastically, water supplies. This leads to contamination of drinking water and can cause hazards to human health as well as effecting the ecosystems. Advantages: Because of it's high levels of toxicity (MORE)

When should inline functions be used?

Inline functions should be used when either the code that the function will contain is minimal (maybe one line or two), or where the function will be called very often.

What are the disadvantages of inline function in c plus plus?

The only disadvantage to inline functions is the increased code size, which can be detrimental to performance, even with the reduced number of function calls. However, declaring a function inline is no guarantee it will be inline expanded; the compiler is free to ignore the declaration if the increa (MORE)

Which is preferred to use in a program Macros or functions?

Definitely functions, since they provide type safety. Many macros also generate unwanted behavior, because of the way they're expanded. In my opinion, just use inline functions, but if it seems appropriate to use macros, use them -- but do so, with caution.

What is the advantages of using MACRO in Excel?

Macros are useful for automating regular tasks that people undertake. It enables people to program more complex tasks that cannot be done as easily with regular formulas. Macros are useful for automating regular tasks that people undertake. It enables people to program more complex tasks that canno (MORE)

What is the difference between macro and inline?

Preprocessor macros are a text substitution pattern that is applied throughout your code prior to compilation. Inline functions are actual functions that are inline expanded, replacing every call to those functions with inline code. But while macros can be used to simulate inline expansion, it is ne (MORE)

What is a macro and its advantages?

Macros are used to provide conditional compilation and inlineexpansion through text substitution. Macros are processed by thepreprocessor not by the compiler. The role of the preprocessor isto modify source code, stripping out all user-defined comments andacting upon preprocessor directives (all lin (MORE)

What are macros and what are its disadvantages?

All macros are defined with the #define directive: #define NDEBUG Note that macro names are always written in uppercase. This is byconvention and makes them much easier to spot in code.. Here we've defined the macro NDEBUG. This is a standard macro usedby many C libraries to provide conditional (MORE)

How does inline function differ from preprocessor macro in c plus plus?

Preprocessor macros are always inline expanded whereas inlinefunctions are only expanded when there is an advantage in doing so.Trivial functions often make ideal candidates as do largerfunctions that are seldom called, however for other functions,inline expansion increases code size and that can ha (MORE)