answersLogoWhite

0


Best Answer

An enumeration is a group of named integral constants. An enumeration is also a type thus it provides type safety. When passing a constant to a function, an enumeration eliminate values that are not part of the group, thus allowing the compiler to catch errors that would otherwise slip through.

A set or pre-processor definitions (or macro definitions) do not provide any type safety and are never actually seen by compiler (they are processed before the compiler sees the resultant code). Macros are nothing more than a text-replacement system that effectively allow programmers to create a language within the programming language and thus create code that would be difficult if not impossible to produce using the language alone. However, when the language provides a simpler, type-safe mechanism, it is always better to utilise it and thus enlist the help of the compiler to eliminate errors. Macros do have their uses, particularly when debugging, but they must be used only when it is appropriate to do so. Enumerations are preferred over a set of macro definitions every time.

Some languages also permit enumeration classes, which gives stronger guarantees than a "plain" enumeration, not least eliminating the implicit promotion between enumerated types and integral types.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Enums are compile time substituted constants whereas #defines are preprocessing substituted time constants

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between enumeration and set of preprocessor define in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the difference between preprocessor directives and header files?

Preprocessor: All the preprocessor commands written in a high level language are processed by the preprocessor before compiler takes over.Example: "#define MAX_ROWS 10"Preprocessor finds all the places and replaces MAX_ROWS with 10 in the files of the project.Compiler: This software, converts the code written in high-level language into object file. Compiler converts all the files of a given project at once.


What is preprocessor derective in C language?

#if, #define, #include just to name a few


What is the use of define key word in c?

Actually, the preprocessor is not part of the C compiler, but here you are: #define is meant to define symbols. Examples #define NULL ((void *)0) #define getchar() getc(stdin)


Write a preprocessor directive to accomplish Define symbolic constant YES to have the value 1?

I'm not exactly sure that this is a question, but here you are:#define YES 1


What is the difference in use of define and const variable?

1.type checking in const that is not a part of #define. 2.scope 3.debugging is possible with const.const variable can be localized whereas #define variable cannot be done so.#define simply replaces whatever you have defined by the text you want it to replace.const variable's value cannot be manipulated during the course of the program.#define is a text preprocessor command and like all text preprocessor commands (beginning with "#") are handled by textual substitution throughout the code before the compiler sees any of the code.const is a compiler keyword that identifies a constant declaration. It is handled by the actual compiler.

Related questions

What is the difference between preprocessor directives and header files?

Preprocessor: All the preprocessor commands written in a high level language are processed by the preprocessor before compiler takes over.Example: "#define MAX_ROWS 10"Preprocessor finds all the places and replaces MAX_ROWS with 10 in the files of the project.Compiler: This software, converts the code written in high-level language into object file. Compiler converts all the files of a given project at once.


What is preprocessor derective in C language?

#if, #define, #include just to name a few


What is directives in c?

It's either the preprocessor instructions (#include #define etc), or the pragmas.


What is a pre-processor directive?

#include is a preprocessor directive. So is #define, #if, etc


How do you set global variables to on?

You can use the preprocessor directive #define, or you can describe a variable in the body of main(). With the preprocessor directive you can make the variable accessible even out of your current project.


What is difference between define and cons Explain with suitable example?

Difference between define and cons is that, con is disadvantage, whereas define means to elaborate something fully.


What is the use of define key word in c?

Actually, the preprocessor is not part of the C compiler, but here you are: #define is meant to define symbols. Examples #define NULL ((void *)0) #define getchar() getc(stdin)


How do you define difference between a 105 and is2062?

how to identify difference between A 105 and IS 2062


Write a preprocessor directive to accomplish define macro square volume that computes the volume of a square the macro takes one argument?

Pick one: #define SQUARE_AREA(A) ((A) * (A)) #define CUBE_VOLUME(A) ((A) * (A) * (A))


Write a preprocessor directive to accomplish Define symbolic constant YES to have the value 1?

I'm not exactly sure that this is a question, but here you are:#define YES 1


Define the 'potential difference between the ends of a conductor'?

The potential difference between the ends of a conductor is called voltage.


What are the function of a processor?

The preprocessor handles directives for source file inclusion (#include), macro definitions (#define), and conditional inclusion (#if).