Thread: defines in do ... while

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    14

    defines in do ... while

    My compiler (Code Warrior) is not liking when I use a define in my do...while:

    Code:
    #define		sepMatch	1;
    #define		sepNoMatch	0;
    
    
    	do{
    // stuff
    	} while (found != sepMatch);
    Should I be coding it differently?

    Thanks

    Greg

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Don't use semicolon at the end of #define

    In your example, the preprocessed code would look something like
    Code:
    while (found != 1;);
    Most likely the compiler will be very confused and say something about missing parenthesis or similar.

    --
    Mats

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    14
    the compiler will be very confused and say something about missing parenthesis
    Can you see my screen from there?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class that defines a location??
    By Codedecode in forum C++ Programming
    Replies: 13
    Last Post: 05-10-2008, 02:44 PM
  2. Trying to redefine library #defines
    By Mario F. in forum C++ Programming
    Replies: 4
    Last Post: 06-18-2007, 07:30 AM
  3. defines take up less space
    By Stan100 in forum Game Programming
    Replies: 5
    Last Post: 10-21-2003, 01:42 AM
  4. Using #define's in C++. Your opinion...
    By biosx in forum C++ Programming
    Replies: 4
    Last Post: 12-07-2002, 08:31 PM
  5. const's and #Defines
    By Dimeslime99 in forum C Programming
    Replies: 9
    Last Post: 07-15-2002, 10:20 PM