View Single Post
  #9   Spotlight this post!  
Unread 04-29-2005, 05:48 PM
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: #define and #ifdef/endif

Yup, we do it all the time. Remember that when you do a #include that it is the same thing as copy/pasting the included file into your current file.

One thing to be careful of is that enums have scope, so you will want to be careful with the way you name your constants.

If you ran the following
Code:
enum
{
  A=1,
  B
};

void my_function(void)
{
   enum
   {
      B = 4
   }
   printf("A: %d  B: %d\n",A,B);
}

void main(void)
{
     printf("A: %d  B: %d\n",A,B);
     my_function();
     printf("A: %d  B: %d\n",A,B);
}
Your output would be
Code:
A: 1 B: 2
A: 1 B: 4
A: 1 B: 2