Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

enemarations vs #define

Status
Not open for further replies.

naresh850

Full Member level 3
Joined
Jun 9, 2006
Messages
157
Helped
6
Reputation
12
Reaction score
4
Trophy points
1,298
Activity points
2,249
Hi,

can anybody tell me which is used better for constants
enemarations or #define
 

Normally Enums are preffered. they more more maintainable in the long run...
 

First, macros(# define) don't observe the usual scope rules. If you declare a macro in a local scope, don't expect it to stay there. Second, some compilers don't preserve macro names for use by symbolic debuggers.

Avoiding macros leaves you with a choice of enumeration... :)
 

#define, the problem is its not type safe. thatz one of the major reason why enumeration would be preffered out of these 2
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top