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
 

sinu_gowde

Full Member level 2
Joined
Nov 10, 2005
Messages
137
Helped
32
Reputation
64
Reaction score
12
Trophy points
1,298
Activity points
3,490
Normally Enums are preffered. they more more maintainable in the long run...
 

sinu_gowde

Full Member level 2
Joined
Nov 10, 2005
Messages
137
Helped
32
Reputation
64
Reaction score
12
Trophy points
1,298
Activity points
3,490
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... :)
 

mondunno

Advanced Member level 4
Joined
Jan 11, 2007
Messages
119
Helped
15
Reputation
30
Reaction score
4
Trophy points
1,298
Activity points
1,907
#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

Top