Thread: compiler warnings

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    175

    compiler warnings

    I have following macro embedded in my code. When code in compiled using Borland 4.0 it gives warning

    Code:
    #define GET_ASCII(n) ( (n >= 0) && (n <= 9) ) ? ( n + '0' ) : ( 'a' +  n - 10 ) )
    Warning: Condition is always true in function xxxx.

    But VC 6 do not show this warning.

    May I know, what is this about and how to remove this?
    I get similar warning for another couple of 'if' conditions.

    Please let me know.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Your parens aren't balenced...you have an extra ")" at the end

    gg

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    175
    Even after balancing the parantheses, I am getting the same warning.

    And as per Salem, parameter that I am passing to macro is unsigned. I tried passing some signed character and it did not show this warning.

    But, can you suggest me how to get rid of this warning?

    Also as I mentioned, it is showing same warning at other if conditions

    e.g.
    # define MAX_TABLE 100

    if ( (id < MAX_TABLE) && (Elements) && (Id >= 0) )

    As element and id both are unsigned, it is giving "always TRUE" warning( per second and third condition)
    But id can greater than 100 also( first condition), then why is it giving this warning?

    Given second and third condition alone in 'if' statement and throwing "Alwayws TRUE" warning looks ok. But should not show up the warning with first condition.

    Please let me know

    Thanks in advance..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 11:28 AM
  2. Compiler "Warnings"
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-24-2005, 01:09 PM
  3. Help With finding a compiler
    By macman in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 04-15-2005, 08:15 AM
  4. Compiler questions
    By DvdHeijden in forum C++ Programming
    Replies: 6
    Last Post: 01-17-2005, 03:00 PM
  5. Have you ever written a compiler?
    By ammar in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 12-27-2004, 07:10 AM