answersLogoWhite

0

Subroutine:

1.When a task is to be done repeatedly then it is written as subroutine and this subroutine will be called each time to perform that task.

2.Subroutine program will be stored in some memory location and program control will be transfered to that location each time.

3.where as in macro the number of instructions will be less than subroutine.Here each time u call a macro that set of instructions will be inserted in that location.

4.macro doesn't have return statement while subroutine has.

5.memory requirement for macro is higher.

6.execution time of macro is lesser than subroutine.

User Avatar

Wiki User

10y ago

What else can I help you with?

Continue Learning about Engineering

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 preprocessed code, not the original source code, and therefore cannot debug macros because the macros no longer exist at that point. Inline functions are functions that can be debugged like any other function, but the compiler is able to eliminate the overhead of function calla by replacing those calls with inline expanded code. This is not unlike a macro, which is by definition inline expanded, but retains the built-in type safety and debugging capabilities of the C++ language itself. Typically, if you can use an inline function (or C++ is general) then that is always the preferred option. But if a macro can achieve more than can be achieved with C++ alone, or can otherwise simplify the equivalent C++ code, then use a macro. Just keep in mind that macros are not type-safe and cannot be debugged by the C++ compiler.


Elements of assembly language programming What is A simple assembly scheme pass structure of assembler design of two pass assemblers a single pass assemblers what is macros?

what are the elements of assembly language programming?


Most c plus plus programmers use uppercase letters for variable names true or false?

False. Most C++ programmers use uppercase for macros (precompiler definitions), making them less likely to be confused with actual variables, constants or functions in the C++ source code. Macros are not actually part of the C++ language because the compiler never sees them, but they allow the precompiler to perform preprocessing tasks that would be difficult or impossible to accomplish with C++ code alone.


Assembly language to machine language translation is?

Assembly language to machine code translation is a "one to one" translation process, as every individual instruction expressed in the assembly language corresponds to exactly one machine instruction. Note this does not hold for pseudo instructions or expanding macros, which are supported by some assemblers.


What are the difference between template and macro?

They both do pretty much the same thing: they both generate code. However, macros are not type-safe, they aren't even type-aware. So if a function body has to generate a type from its argument, then you cannot use a macro, you must use a template. Even if that is not an issue, the lack of type-safety is a major drawback in a strongly-typed language like C++. Remember, macros are not part of the language itself, they simply exist to augment the language by providing simple text replacements, ultimately making code easier to read and understand. Using them in place of function or class templates is never a good idea no matter how simple the function or class. A bit of extra typing can save a mountain of headaches. The biggest problem with macros (besides their lack of type awareness) is that they are extremely difficult to debug because they are inline expanded by the preprocessor. This means that if the compiler detects and error, it can only do so in the expanded code which simply doesn't exist in your source code. This also means you cannot set breakpoints in a macro because the macro won't physically exist in the preprocessed code. Macros can be used to generate any code except the definition of another macro. This can be extremely useful and is extremely powerful when used appropriately. However, templates can only generate explicit dynamic data types and explicit function overloads. A macro that merely emulates a template is therefore not a particularly useful macro, it is an abhorrent abuse of the language and its compiler. The compiler is there to help you so you are encouraged to enlist it as much as possible. The min/max macros are often quoted as being simpler and easier to use and understand than their equivalent template functions. However, they actually demonstrate why macro functions are so bad in the first place. Calling max(++a, b++) will quickly dispel any myths about macros being easier to work with. Macros completely ignore namespaces and scope, which can result in name clashes that will produce some really funky code. By contrast, templates are fully namespace and scope aware.

Related Questions

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 types of macros are available in Flowcode?

Component Macros are built in functions used to control components such as an LCD display, EEPROM, switches, serial data, etc. Macros are user created functions that help make the program more modular. As far as I can tell, there are only those 2 types.


Which header files contain declaration for the files input and output functions and the macros defined and that are used with file input and output functions?

stdio.h


How marketing functions can be shifted and shared?

Marketing functions for macros cannot be shifted or shared. They must all be processed by someone and none can be left out.


What are the icons in Microsoft Word 2007 and their functions?

Word 2007 file extensions have been changed as noted below :Type FileWord 2007 document without macros .docxWord 2007 document with macros .docmWord 2007 Template without macros .dotxWord 2007 Template with macros .dotm


What is the difference between macros in Microsoft Word and Microsoft Excel?

Not much, except that the macros would be written to perform different tasks, because Word (word processor) and Excel (spreadsheet) have different functions. Both are written by the user to perform a specific task, but since each application handles most tasks differently, the macros would need to be designed for the tasks relevant to the specific application.


What is the difference between macros and wizard?

a wizard inserts fields and a macros is something like a hyperlink that when you click on it, it automatically takes you to another page!


Can you leave blank lines between macros in a macro group?

No, because Access will interpret a blank line as no further action and stop executing the macros.


Will openoffice crash with macros?

The honest answer is: "OpenOffice.org is software and therefore can crash as any software." However, the more interesting question is does OpenOffice.org support macros? The answer is: Yes and No! OpenOffice.org does support its own macro language. However the standard edition (as of release 2.3) does not support Visual Basic Macros, as used in Microsoft Office. There are editions of OpenOffice, that support VBA macros.


What are the complex technical functions offered by the word processing package?

form fields, linking, macros, table of contents, styles


Why you use ctype.h in c language?

it contains the information used by character classification and character conversion macros


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 preprocessed code, not the original source code, and therefore cannot debug macros because the macros no longer exist at that point. Inline functions are functions that can be debugged like any other function, but the compiler is able to eliminate the overhead of function calla by replacing those calls with inline expanded code. This is not unlike a macro, which is by definition inline expanded, but retains the built-in type safety and debugging capabilities of the C++ language itself. Typically, if you can use an inline function (or C++ is general) then that is always the preferred option. But if a macro can achieve more than can be achieved with C++ alone, or can otherwise simplify the equivalent C++ code, then use a macro. Just keep in mind that macros are not type-safe and cannot be debugged by the C++ compiler.