Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating constants like enum constants with a macro

Status
Not open for further replies.

rtoe

Programmer
Nov 30, 2007
1
FR
I'd like to have a macro to call which increments an ID. This ID is a constant, being incremented each time it is called.

Obviously, the following does not work:
#define ID 0 // initially
.. then
#define ID ID+1 // whenever I need a new ID generated.

Is there a trick, potentially with multiple macros to solve this seemingly trivial problem?

thx!
 
Answered already at about.com


--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top