Thread: See anything wrong with this simple line?

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    12

    See anything wrong with this simple line?

    Hello All,

    I am getting an error with what seems to be very simple. Here it is
    Code:
    if (!GPIO_ReadInputPin(BUTTON_PORT,BUTTON_PIN) && (button_db > DEBOUNCE_TIME))  {    button_press_gf = TRUE; }
    
    The compiler says it is expecting a ")". What am I missing here? I know the function call is ok.

  2. #2
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Are you sure that this line has the error?It seems ok

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    12
    Yes. It seems fine, doesn't it. I just broke it up like this:
    Code:
     
    if (!GPIO_ReadInputPin(BUTTON_PORT,BUTTON_PIN))    {       if (button_db > DEBOUNCE_TIME) button_press_gf = TRUE;    }
    


    It is flagging the error in the inner statement.

  4. #4
    Registered User
    Join Date
    Mar 2012
    Posts
    12
    LOL. I just found my stupid error. I ended the DEBOUNCE_TIME definition with a semicolon.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    My guess is you should look at the macro DEBOUNCE_TIME to see whether it has mis-matched ( )

    Also, you can try this
    gcc -E prog.c > prog.i
    prog.i will be the result AFTER the pre-processor has expanded all macros, and included all files.

    Other compilers have a similar option.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    There are no stupid errors.You just did not notice it

  7. #7
    Registered User
    Join Date
    Mar 2012
    Posts
    12
    Quote Originally Posted by Salem View Post
    My guess is you should look at the macro DEBOUNCE_TIME to see whether it has mis-matched ( )

    Also, you can try this
    gcc -E prog.c > prog.i
    prog.i will be the result AFTER the pre-processor has expanded all macros, and included all files.

    Other compilers have a similar option.
    That is correct. I had the define line as:

    Code:
     
    #define DEBOUNCE_TIME 30;
    
    Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What is wrong on last line of this code???
    By jacob_76505 in forum C Programming
    Replies: 3
    Last Post: 10-08-2011, 05:00 PM
  2. what is wrong with this line?
    By Farnaz in forum C++ Programming
    Replies: 1
    Last Post: 06-03-2011, 07:11 AM
  3. Error in printf line,,,what's wrong?
    By mft_ika in forum C Programming
    Replies: 9
    Last Post: 03-19-2010, 08:46 PM
  4. What's wrong in this line of code?
    By marCplusplus in forum C++ Programming
    Replies: 12
    Last Post: 12-12-2001, 09:16 AM
  5. command line program, something wrong in the argv
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 09-26-2001, 09:36 AM